1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | |
---|
4 | """ |
---|
5 | This file is part of the web2py Web Framework |
---|
6 | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> |
---|
7 | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) |
---|
8 | |
---|
9 | This is a handler for lighttpd+fastcgi |
---|
10 | This file has to be in the PYTHONPATH |
---|
11 | Put something like this in the lighttpd.conf file: |
---|
12 | |
---|
13 | server.port = 8000 |
---|
14 | server.bind = '127.0.0.1' |
---|
15 | server.event-handler = 'freebsd-kqueue' |
---|
16 | server.modules = ('mod_rewrite', 'mod_fastcgi') |
---|
17 | server.error-handler-404 = '/test.fcgi' |
---|
18 | server.document-root = '/somewhere/web2py' |
---|
19 | server.errorlog = '/tmp/error.log' |
---|
20 | fastcgi.server = ('.fcgi' => |
---|
21 | ('localhost' => |
---|
22 | ('min-procs' => 1, |
---|
23 | 'socket' => '/tmp/fcgi.sock' |
---|
24 | ) |
---|
25 | ) |
---|
26 | ) |
---|
27 | """ |
---|
28 | |
---|
29 | LOGGING = False |
---|
30 | SOFTCRON = False |
---|
31 | |
---|
32 | import sys |
---|
33 | import os |
---|
34 | |
---|
35 | path = os.path.dirname(os.path.abspath(__file__)) |
---|
36 | os.chdir(path) |
---|
37 | |
---|
38 | if not os.path.isdir('applications'): |
---|
39 | raise RuntimeError('Running from the wrong folder') |
---|
40 | |
---|
41 | sys.path = [path] + [p for p in sys.path if not p == path] |
---|
42 | |
---|
43 | import gluon.main |
---|
44 | import gluon.contrib.gateways.fcgi as fcgi |
---|
45 | |
---|
46 | if LOGGING: |
---|
47 | application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase, |
---|
48 | logfilename='httpserver.log', |
---|
49 | profiler_dir=None) |
---|
50 | else: |
---|
51 | application = gluon.main.wsgibase |
---|
52 | |
---|
53 | if SOFTCRON: |
---|
54 | from gluon.settings import global_settings |
---|
55 | global_settings.web2py_crontype = 'soft' |
---|
56 | |
---|
57 | fcgi.WSGIServer(application, bindAddress='/tmp/fcgi.sock').run() |
---|