source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/handlers/scgihandler.py @ 42095c5

mainqndtest v1.1.1
Last change on this file since 42095c5 was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 2.1 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5scgihandler.py - handler for SCGI protocol
6
7Modified by Michele Comitini <michele.comitini@glisco.it>
8from fcgihandler.py to support SCGI
9
10fcgihandler has the following copyright:
11" This file is part of the web2py Web Framework
12  Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
13  License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
14"
15
16This is a handler for lighttpd+scgi
17This file has to be in the PYTHONPATH
18Put something like this in the lighttpd.conf file:
19
20server.document-root="/var/www/web2py/"
21# for >= linux-2.6
22server.event-handler = "linux-sysepoll"
23
24url.rewrite-once = (
25      "^(/.+?/static/.+)$" => "/applications$1",
26      "(^|/.*)$" => "/handler_web2py.scgi$1",
27)
28scgi.server = ( "/handler_web2py.scgi" =>
29                  ("handler_web2py" =>
30                      ( "host" => "127.0.0.1",
31                        "port" => "4000",
32                        "check-local" => "disable", # don't forget to set "disable"!
33                      )
34    )
35)
36
37
38
39
40"""
41
42LOGGING = False
43SOFTCRON = False
44
45import sys
46import os
47
48path = os.path.dirname(os.path.abspath(__file__))
49os.chdir(path)
50
51if not os.path.isdir('applications'):
52    raise RuntimeError('Running from the wrong folder')
53
54sys.path = [path] + [p for p in sys.path if not p == path]
55
56import gluon.main
57
58# uncomment one of the two imports below depending on the SCGIWSGI server installed
59#import paste.util.scgiserver as scgi
60from wsgitools.scgi.forkpool import SCGIServer
61from wsgitools.filters import WSGIFilterMiddleware, GzipWSGIFilter
62
63wsgiapp = WSGIFilterMiddleware(gluon.main.wsgibase, GzipWSGIFilter)
64
65if LOGGING:
66    application = gluon.main.appfactory(wsgiapp=wsgiapp,
67                                        logfilename='httpserver.log',
68                                        profiler_dir=None)
69else:
70    application = wsgiapp
71
72if SOFTCRON:
73    from gluon.settings import global_settings
74    global_settings.web2py_crontype = 'soft'
75
76# uncomment one of the two rows below depending on the SCGIWSGI server installed
77#scgi.serve_application(application, '', 4000).run()
78SCGIServer(application, port=4000).enable_sighandler().run()
Note: See TracBrowser for help on using the repository browser.