Commit 1c726667 authored by Gero Müller's avatar Gero Müller
Browse files

fix wsgi mode

parent fcb8f1d3
......@@ -342,4 +342,5 @@ def dump_thread_status_on_signal(signal, stack):
dump_thread_status(f)
signal.signal(signal.SIGUSR2, dump_thread_status_on_signal)
def setup_thread_dump():
signal.signal(signal.SIGUSR2, dump_thread_status_on_signal)
......@@ -159,7 +159,7 @@ class Server(object):
def __init__(self, **kwargs):
self.__init_paths(**kwargs)
self.__init_logging(**kwargs)
#self.__init_logging(**kwargs)
self.__init_database(**kwargs)
self.__init_tools(**kwargs)
self.__init_platform(**kwargs)
......@@ -243,12 +243,16 @@ class Server(object):
sql_base.metadata.create_all(self._engine)
def __init_plugins(self, **kwargs):
logger.info("init plugins")
if vispa.config('websockets', 'enabled', False):
from ws4py.server.cherrypyserver import WebSocketPlugin
WebSocketPlugin(cherrypy.engine).subscribe()
logger.info("create bus")
from vispa.socketbus import Bus
vispa.bus = Bus()
logger.info("setup templates")
mako_lookup_dir = os.path.join(os.path.dirname(__file__), "templates")
vispa.plugins.template.MakoPlugin(cherrypy.engine,
base_dir=mako_lookup_dir,
......@@ -303,10 +307,13 @@ class Server(object):
if port:
cherrypy.config.update({'server.socket_port': int(port)})
logger.info("create root controller")
from vispa.controller.root import RootController
self.controller = RootController()
logger.info("load extensions")
self._load_extensions()
script_name = vispa.url.dynamic('/', encoding='utf-8')
logger.info("mount app")
self.__application = cherrypy.tree.mount(self.controller, script_name,
self.__default_mount_config())
if os.path.isfile(cherrypy_conf):
......@@ -316,6 +323,7 @@ class Server(object):
if hasattr(cherrypy.engine, 'signal_handler'):
cherrypy.engine.signal_handler.subscribe()
cherrypy.engine.start()
vispa.setup_thread_dump()
def stop(self):
cherrypy.engine.stop()
......
import logging
import logging.config
import os
import cherrypy
logger = logging.getLogger(__name__)
vispa_server = None
cherrypy.config.update({'environment': 'embedded'})
def application(environ, start_response):
global vispa_server
......@@ -25,18 +24,16 @@ def application(environ, start_response):
'VISPA_DATA_PATH',
datadir)
loglevel = os.environ.get(
'VISPA_LOG_LEVEL',
None)
loglevel = environ.get(
'VISPA_LOG_LEVEL',
loglevel)
logging_conf = os.path.join(configdir, 'logging.ini')
if os.path.isfile(logging_conf):
logging.config.fileConfig(logging_conf)
logger = logging.getLogger(__name__)
from vispa import server
vispa_server = server.Server(
configdir=configdir,
datadir=datadir,
loglevel=loglevel)
vispa_server.start()
vardir=datadir)
cherrypy.server.unsubscribe()
cherrypy.engine.start()
logger.info("server startet.")
return cherrypy.tree(environ, start_response)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment