Source

Dragoman / dragoman / control / root.py

Full commit
import os
import cherrypy

from eggmonster import env

from dragoman.control.urls import urls
from dragoman.etc import startup


def setup_app(extra_conf=None):
    config = {
        '/': {
            'request.dispatch': urls,
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8'
        },

        '/static' : {
            'tools.staticdir.on' : True,
            'tools.staticdir.dir' : os.path.join(env.base, 'static'),
        },
    }
    cherrypy.tree.mount(root=None, config=config)


def run():
    setup_app()
    conf = {
        'checker.on': False,
        'log.screen' : True,        
        'server.socket_port' : env.get('port', 5000),
        'server.socket_host': '0.0.0.0',
        'engine.autoreload_on': True
    }

    if not env.get('debug', False):
        conf['environment'] = 'production'
        
    if env.get('threads'):
        conf.update({'server.thread_pool' : env.get('threads')})

    cherrypy.config.update(conf)
    cherrypy.server.quickstart()
    cherrypy.engine.start()

if __name__ == '__main__':
    run()