X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/021528d994812f6e794cffbd098109ced57866a3..2be0969e153ace507ec07b27d156b50e54e00f94:/code/invirt.fcgi diff --git a/code/invirt.fcgi b/code/invirt.fcgi index 0bce132..ded6b68 100755 --- a/code/invirt.fcgi +++ b/code/invirt.fcgi @@ -13,33 +13,36 @@ base_dir = os.path.dirname(__file__) def usage(): argv0_dir = os.path.dirname(sys.argv[0]) print >>sys.stderr, """%s [config] + +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, or pass -'auth' or 'unauth' as the first parameter. +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) > 3 or len(sys.argv) == 1 or '-h' in sys.argv or '--help' in sys.argv: + if '-h' in sys.argv or '--help' in sys.argv: usage() + if not (2 <= len(sys.argv) <= 3): + usage() + + mode = sys.argv[1] if len(sys.argv) == 3: - mode = sys.argv[1] conf_file = sys.argv[2] dev = True else: - mode = sys.argv[1] conf_file = os.path.join(base_dir, 'main.conf') app_config = { '/': { 'tools.invirtwebstate.on': True, + 'tools.clear_db_cache.on': True, }, } @@ -61,7 +64,12 @@ if __name__ == "__main__": cherrypy.engine.start() cherrypy.engine.block() else: - cherrypy.engine.start(blocking=False) + cherrypy.server.unsubscribe() + 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()