source: package_branches/invirt-web/cherrypy-rebased/code/auth.fcgi @ 2732

Last change on this file since 2732 was 2732, checked in by broder, 15 years ago

Don't calculate static_dir in the fcgi files - we no longer use it
there.

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/usr/bin/python
2"""Main FastCGI entry point for authenticated web interface"""
3
4import cherrypy
5import os
6import sys
7from main import InvirtWeb
8
9dev = False
10base_dir = os.path.dirname(__file__)
11
12def usage():
13    print >>sys.stderr, """%s [config]
14
15Run server as FastCGI, with CherryPy config from "main.conf".
16
17With `config`, run standalone with CherryPy config from `config`.
18""" % sys.argv[0]
19    sys.exit(2)
20
21if __name__ == "__main__":
22    if len(sys.argv) > 2:
23        usage()
24    if len(sys.argv) > 1:
25        if sys.argv[1] in ('-h', '--help'):
26            usage()
27        conf_file = sys.argv[1]
28        dev = True
29    else:
30        conf_file = os.path.join(base_dir, 'main.conf')
31
32    app_config = {
33        '/': {
34            'tools.invirtwebstate.on': True,
35            },
36        }
37                   
38    app = cherrypy.tree.mount(InvirtWeb(),
39                              '/',
40                              app_config)
41    app.merge(conf_file)
42    cherrypy.config.update(conf_file)
43
44    if dev:
45        cherrypy.server.quickstart()
46        cherrypy.engine.start()
47        cherrypy.engine.block()
48    else:
49        cherrypy.engine.start(blocking=False)
50        from flup.server.fcgi import WSGIServer
51        server = WSGIServer(cherrypy.tree)
52        server.run()
Note: See TracBrowser for help on using the repository browser.