2 """Main FastCGI entry point for web interface"""
11 base_dir = os.path.dirname(__file__)
14 argv0_dir = os.path.dirname(sys.argv[0])
15 print >>sys.stderr, """%s <unauth|auth> [config]
17 Run server as FastCGI, with CherryPy config from "main.conf".
18 With `config`, run standalone with CherryPy config from `config`.
20 Serve the authenticated or unauthenticated site according to
23 Helper scripts "auth.fcgi" and "unauth.fcgi" are provided to
24 facilitate running the server with no arguments.
25 """ % (sys.argv[0], argv0_dir, argv0_dir)
28 if __name__ == "__main__":
29 if '-h' in sys.argv or '--help' in sys.argv:
31 if not (2 <= len(sys.argv) <= 3):
35 if len(sys.argv) == 3:
36 conf_file = sys.argv[2]
39 conf_file = os.path.join(base_dir, 'main.conf')
43 'tools.invirtwebstate.on': True,
47 if mode.startswith('auth'):
48 root = main.InvirtWeb()
49 app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-auth-web-templatecache"
50 elif mode.startswith('unauth'):
51 root = main.InvirtUnauthWeb()
52 app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-unauth-web-templatecache"
56 app = cherrypy.tree.mount(root, '/', app_config)
58 cherrypy.config.update(conf_file)
61 cherrypy.server.quickstart()
62 cherrypy.engine.start()
63 cherrypy.engine.block()
65 cherrypy.engine.start(blocking=False)
66 from flup.server.fcgi import WSGIServer
67 server = WSGIServer(cherrypy.tree)