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 Or via the provided wrapper scripts:
19 %s/unauth.fcgi [config]
21 Run server as FastCGI, with CherryPy config from "main.conf".
22 With `config`, run standalone with CherryPy config from `config`.
24 Serve the authenticated site with 'auth' or under 'auth.fcgi',
25 and the unauthenticated site with 'unauth' or under 'unauth.fcgi'.
26 """ % (sys.argv[0], argv0_dir, argv0_dir)
29 if __name__ == "__main__":
30 if '-h' in sys.argv or '--help' in sys.argv:
32 if not (2 <= len(sys.argv) <= 3):
36 if len(sys.argv) == 3:
37 conf_file = sys.argv[2]
40 conf_file = os.path.join(base_dir, 'main.conf')
44 'tools.invirtwebstate.on': True,
45 'tools.clear_db_cache.on': True,
49 if mode.startswith('auth'):
50 root = main.InvirtWeb()
51 app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-auth-web-templatecache"
52 elif mode.startswith('unauth'):
53 root = main.InvirtUnauthWeb()
54 app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-unauth-web-templatecache"
58 app = cherrypy.tree.mount(root, '/', app_config)
60 cherrypy.config.update(conf_file)
63 cherrypy.server.quickstart()
64 cherrypy.engine.start()
65 cherrypy.engine.block()
67 cherrypy.engine.start(blocking=False)
68 from flup.server.fcgi import WSGIServer
69 server = WSGIServer(cherrypy.tree)