source: package_branches/invirt-web/cherrypy/code/unauth.fcgi @ 2651

Last change on this file since 2651 was 2651, checked in by broder, 15 years ago

Use separate fcgi files for the authed and unauthed site.

This allows both of them to be mounted on / in their respective
CherryPy? apps, which in turn eliminates any discrepancy between
"internal URLs" and "external URLs".

  • Property svn:executable set to *
File size: 1.5 KB
RevLine 
[579]1#!/usr/bin/python
[2651]2"""Main FastCGI entry point for unauthenticated web interface"""
[2386]3
4import cherrypy
5import os
6import sys
[2651]7from main import InvirtUnauthWeb
[2386]8
9dev = False
10base_dir = os.path.dirname(__file__)
11
[2521]12def usage():
13    print >>sys.stderr, """%s [config]
14
15Run server as FastCGI, with CherryPy config from "main.conf".
16
17With `config`, run standalone with CherryPy config from `config`.
18""" % sys.argv[0]
19    sys.exit(2)
20
21if __name__ == "__main__":
[2387]22    static_dir = os.path.join(base_dir, 'static')
23
[2521]24    if len(sys.argv) > 2:
25        usage()
[2386]26    if len(sys.argv) > 1:
[2521]27        if sys.argv[1] in ('-h', '--help'):
28            usage()
[2386]29        conf_file = sys.argv[1]
30        dev = True
31    else:
32        conf_file = os.path.join(base_dir, 'main.conf')
[2650]33
34    app_config = {
35        '/': {
36            'tools.invirtwebstate.on': True,
37            },
38        '/static': {
39            'tools.staticdir.root': static_dir,
40            'tools.staticdir.on': True,
41            'tools.staticdir.dir': static_dir,
42            }
43        }
44                   
[2651]45    app = cherrypy.tree.mount(InvirtUnauthWeb(),
46                              '/',
47                              app_config)
48    app.merge(conf_file)
[2386]49    cherrypy.config.update(conf_file)
50
51    if dev:
52        cherrypy.server.quickstart()
53        cherrypy.engine.start()
54        cherrypy.engine.block()
55    else:
56        cherrypy.engine.start(blocking=False)
57        from flup.server.fcgi import WSGIServer
[2484]58        server = WSGIServer(cherrypy.tree)
[2386]59        server.run()
Note: See TracBrowser for help on using the repository browser.