source: package_branches/invirt-web/cherrypy-rebased/code/unauth.fcgi @ 2730

Last change on this file since 2730 was 2730, checked in by broder, 14 years ago

Setup hosting for static resources in the InvirtWeb? and
InvirtUnauthWeb? classes, instead of in the fcgi configuration.

  • Property svn:executable set to *
File size: 1.3 KB
RevLine 
[579]1#!/usr/bin/python
[2729]2"""Main FastCGI entry point for unauthenticated web interface"""
[2660]3
4import cherrypy
5import os
6import sys
[2729]7from main import InvirtUnauthWeb
[2660]8
9dev = False
10base_dir = os.path.dirname(__file__)
11
[2702]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__":
[2661]22    static_dir = os.path.join(base_dir, 'static')
23
[2702]24    if len(sys.argv) > 2:
25        usage()
[2660]26    if len(sys.argv) > 1:
[2702]27        if sys.argv[1] in ('-h', '--help'):
28            usage()
[2660]29        conf_file = sys.argv[1]
30        dev = True
31    else:
32        conf_file = os.path.join(base_dir, 'main.conf')
[2728]33
34    app_config = {
35        '/': {
36            'tools.invirtwebstate.on': True,
37            },
38        }
39                   
[2729]40    app = cherrypy.tree.mount(InvirtUnauthWeb(),
41                              '/',
42                              app_config)
43    app.merge(conf_file)
[2660]44    cherrypy.config.update(conf_file)
45
46    if dev:
47        cherrypy.server.quickstart()
48        cherrypy.engine.start()
49        cherrypy.engine.block()
50    else:
51        cherrypy.engine.start(blocking=False)
52        from flup.server.fcgi import WSGIServer
[2692]53        server = WSGIServer(cherrypy.tree)
[2660]54        server.run()
Note: See TracBrowser for help on using the repository browser.