Last change
on this file since 2739 was
2737,
checked in by broder, 15 years ago
|
Merge cherrypy-rebased branch of invirt-web into trunk.
|
-
Property svn:executable set to
*
|
File size:
1.5 KB
|
Rev | Line | |
---|
[579] | 1 | #!/usr/bin/python |
---|
[2733] | 2 | """Main FastCGI entry point for web interface""" |
---|
[2660] | 3 | |
---|
| 4 | import cherrypy |
---|
| 5 | import os |
---|
| 6 | import sys |
---|
| 7 | |
---|
[2733] | 8 | import main |
---|
| 9 | |
---|
[2660] | 10 | dev = False |
---|
| 11 | base_dir = os.path.dirname(__file__) |
---|
| 12 | |
---|
[2702] | 13 | def usage(): |
---|
| 14 | print >>sys.stderr, """%s [config] |
---|
| 15 | |
---|
| 16 | Run server as FastCGI, with CherryPy config from "main.conf". |
---|
| 17 | |
---|
| 18 | With `config`, run standalone with CherryPy config from `config`. |
---|
[2733] | 19 | |
---|
| 20 | Run this script as either 'auth.fcgi' or 'unauth.fcgi', to get |
---|
| 21 | the authenticated or unauthenticated site respectively. |
---|
[2702] | 22 | """ % sys.argv[0] |
---|
| 23 | sys.exit(2) |
---|
| 24 | |
---|
| 25 | if __name__ == "__main__": |
---|
| 26 | if len(sys.argv) > 2: |
---|
| 27 | usage() |
---|
[2660] | 28 | if len(sys.argv) > 1: |
---|
[2702] | 29 | if sys.argv[1] in ('-h', '--help'): |
---|
| 30 | usage() |
---|
[2660] | 31 | conf_file = sys.argv[1] |
---|
| 32 | dev = True |
---|
| 33 | else: |
---|
| 34 | conf_file = os.path.join(base_dir, 'main.conf') |
---|
[2728] | 35 | |
---|
| 36 | app_config = { |
---|
| 37 | '/': { |
---|
| 38 | 'tools.invirtwebstate.on': True, |
---|
| 39 | }, |
---|
| 40 | } |
---|
[2733] | 41 | |
---|
| 42 | if os.path.basename(sys.argv[0]).startswith('auth'): |
---|
[2734] | 43 | root = main.InvirtWeb() |
---|
[2733] | 44 | elif os.path.basename(sys.argv[0]).startswith('unauth'): |
---|
[2734] | 45 | root = main.InvirtUnauthWeb() |
---|
[2733] | 46 | else: |
---|
| 47 | usage() |
---|
| 48 | |
---|
| 49 | app = cherrypy.tree.mount(root, '/', app_config) |
---|
[2729] | 50 | app.merge(conf_file) |
---|
[2660] | 51 | cherrypy.config.update(conf_file) |
---|
| 52 | |
---|
| 53 | if dev: |
---|
| 54 | cherrypy.server.quickstart() |
---|
| 55 | cherrypy.engine.start() |
---|
| 56 | cherrypy.engine.block() |
---|
| 57 | else: |
---|
| 58 | cherrypy.engine.start(blocking=False) |
---|
| 59 | from flup.server.fcgi import WSGIServer |
---|
[2692] | 60 | server = WSGIServer(cherrypy.tree) |
---|
[2660] | 61 | server.run() |
---|
Note: See
TracBrowser
for help on using the repository browser.