source: package_branches/invirt-web/cherrypy/code/main.fcgi @ 2411

Last change on this file since 2411 was 2399, checked in by quentin, 15 years ago

Initialize state object correctly

  • Property svn:executable set to *
File size: 1.0 KB
RevLine 
[579]1#!/usr/bin/python
[2386]2"""Main FastCGI entry point for web interface"""
3
4import cherrypy
5import os
6import sys
7from main import InvirtWeb
8
9dev = False
10base_dir = os.path.dirname(__file__)
11
12if __name__=="__main__":
[2387]13    static_dir = os.path.join(base_dir, 'static')
14
[2386]15    if len(sys.argv) > 1:
16        conf_file = sys.argv[1]
17        dev = True
18    else:
19        conf_file = os.path.join(base_dir, 'main.conf')
[2387]20    app = cherrypy.tree.mount(InvirtWeb(),
21        '/' if dev else '/main.fcgi',
[2399]22        {'/':      {'tools.staticdir.root': static_dir,
23                    'tools.invirtwebstate.on': True},
[2387]24        '/static': {'tools.staticdir.on': True,
25                    'tools.staticdir.dir': static_dir}
26         })
[2386]27    app.merge(conf_file)
28    cherrypy.config.update(conf_file)
29
30    if dev:
31        cherrypy.server.quickstart()
32        cherrypy.engine.start()
33        cherrypy.engine.block()
34    else:
35        cherrypy.engine.start(blocking=False)
36        from flup.server.fcgi import WSGIServer
37        server = WSGIServer(app)
38        server.run()
Note: See TracBrowser for help on using the repository browser.