X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/06d55379f8eaaffe42ca5a1ac59e1cb0633c12e9..9dd8549018d758eccc9768afb4049de2945d2616:/code/invirt.fcgi?ds=inline diff --git a/code/invirt.fcgi b/code/invirt.fcgi old mode 100644 new mode 100755 index 385b562..7d6dc9c --- a/code/invirt.fcgi +++ b/code/invirt.fcgi @@ -11,24 +11,30 @@ dev = False base_dir = os.path.dirname(__file__) def usage(): - print >>sys.stderr, """%s [config] + argv0_dir = os.path.dirname(sys.argv[0]) + print >>sys.stderr, """%s [config] -Run server as FastCGI, with CherryPy config from "main.conf". +Or via the provided wrapper scripts: +%s/auth.fcgi [config] +%s/unauth.fcgi [config] +Run server as FastCGI, with CherryPy config from "main.conf". With `config`, run standalone with CherryPy config from `config`. -Run this script as either 'auth.fcgi' or 'unauth.fcgi', to get -the authenticated or unauthenticated site respectively. -""" % sys.argv[0] +Serve the authenticated site with 'auth' or under 'auth.fcgi', +and the unauthenticated site with 'unauth' or under 'unauth.fcgi'. +""" % (sys.argv[0], argv0_dir, argv0_dir) sys.exit(2) if __name__ == "__main__": - if len(sys.argv) > 2: + if '-h' in sys.argv or '--help' in sys.argv: usage() - if len(sys.argv) > 1: - if sys.argv[1] in ('-h', '--help'): - usage() - conf_file = sys.argv[1] + if not (2 <= len(sys.argv) <= 3): + usage() + + mode = sys.argv[1] + if len(sys.argv) == 3: + conf_file = sys.argv[2] dev = True else: conf_file = os.path.join(base_dir, 'main.conf') @@ -36,13 +42,16 @@ if __name__ == "__main__": app_config = { '/': { 'tools.invirtwebstate.on': True, + 'tools.clear_db_cache.on': True, }, } - if os.path.basename(sys.argv[0]).startswith('auth'): - root = InvirtWeb() - elif os.path.basename(sys.argv[0]).startswith('unauth'): - root = InvirtUnauthWeb() + if mode.startswith('auth'): + root = main.InvirtWeb() + app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-auth-web-templatecache" + elif mode.startswith('unauth'): + root = main.InvirtUnauthWeb() + app_config['/']['tools.mako.module_directory'] = "/tmp/invirt-unauth-web-templatecache" else: usage() @@ -55,7 +64,11 @@ if __name__ == "__main__": cherrypy.engine.start() cherrypy.engine.block() else: - cherrypy.engine.start(blocking=False) + try: + # Case that cherrypy < 3.1.0 + cherrypy.engine.start(blocking=False) + except TypeError: + cherrypy.engine.start() from flup.server.fcgi import WSGIServer server = WSGIServer(cherrypy.tree) server.run()