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 %s/unauth.fcgi [config]
19 Run server as FastCGI, with CherryPy config from "main.conf".
21 With `config`, run standalone with CherryPy config from `config`.
23 Run this script as either 'auth.fcgi' or 'unauth.fcgi', to get
24 the authenticated or unauthenticated site respectively, or pass
25 'auth' or 'unauth' as the first parameter.
26 """ % (sys.argv[0], argv0_dir, argv0_dir)
29 if __name__ == "__main__":
30 if len(sys.argv) > 3 or len(sys.argv) == 1 or '-h' in sys.argv or '--help' in sys.argv:
32 if len(sys.argv) == 3:
34 conf_file = sys.argv[2]
38 conf_file = os.path.join(base_dir, 'main.conf')
42 'tools.invirtwebstate.on': True,
46 if mode.startswith('auth'):
47 root = main.InvirtWeb()
48 app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-auth-web-templatecache"
49 elif mode.startswith('unauth'):
50 root = main.InvirtUnauthWeb()
51 app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-unauth-web-templatecache"
55 app = cherrypy.tree.mount(root, '/', app_config)
57 cherrypy.config.update(conf_file)
60 cherrypy.server.quickstart()
61 cherrypy.engine.start()
62 cherrypy.engine.block()
64 cherrypy.engine.start(blocking=False)
65 from flup.server.fcgi import WSGIServer
66 server = WSGIServer(cherrypy.tree)