Example #1
0
 def start(self, blocking=False):
     """Start the server."""
     obj = DASTestDataService(self.config) # mount test server
     tree.mount(obj, '/')
     self.engine.start()
     if  blocking:
         self.engine.block()
Example #2
0
    def start(self, blocking=True):
        """Configure and start the server."""
        self.configure()
        url_base = self.config['web_server']['url_base']
        config = self.config.get('web_server', {})
        config['engine'] = engine
        obj = DASWebService(self.config)
        tree.mount(obj, url_base) # mount web server

        self.setup_kws_server()

        print "### DAS web server, PID=%s" % self.pid
        print pformat(tree.apps)
        print pformat(self.config)
        pid = PIDFile(engine, self.pid)
        pid.subscribe()
        engine.start()
        print "### DAS server runs with %s threads" \
                % threading.active_count()
        threads = threading.enumerate()
        threads.sort()
        for thr in threads:
            print thr
        if  blocking:
            engine.block()
Example #3
0
    def start(self, blocking=True):
        """Configure and start the server."""
        self.configure()
        url_base = self.config['web_server']['url_base']
        config = self.config.get('web_server', {})
        config['engine'] = engine
        # import DASWebServices after we run self.configure which register secmodv2
        from DAS.web.das_web_srv import DASWebService
        obj = DASWebService(self.config)
        tree.mount(obj, url_base) # mount web server

        self.setup_kws_server()

        print("### DAS web server, PID=%s" % self.pid)
        print(pformat(tree.apps))
        print(pformat(self.config))
        pid = PIDFile(engine, self.pid)
        pid.subscribe()
        engine.start()
        print("### DAS server runs with %s threads" \
                % threading.active_count())
        threads = threading.enumerate()
        try:
            threads.sort()
        except:
            pass
        for thr in threads:
            print(thr)
        if  blocking:
            engine.block()
Example #4
0
    def start(self, blocking=True):
        """Configure and start the server."""
        self.configure()
        url_base = self.config['web_server']['url_base']
        config = self.config.get('web_server', {})
        config['engine'] = engine
        # import DASWebServices after we run self.configure which register secmodv2
        from DAS.web.das_web_srv import DASWebService
        obj = DASWebService(self.config)
        tree.mount(obj, url_base)  # mount web server

        self.setup_kws_server()

        print("### DAS web server, PID=%s" % self.pid)
        print(pformat(tree.apps))
        print(pformat(self.config))
        pid = PIDFile(engine, self.pid)
        pid.subscribe()
        engine.start()
        print("### DAS server runs with %s threads" \
                % threading.active_count())
        threads = threading.enumerate()
        try:
            threads.sort()
        except:
            pass
        for thr in threads:
            print(thr)
        if blocking:
            engine.block()
Example #5
0
def startup(config):
    server.socket_host = config.web_address
    server.socket_port = config.web_port
    tree.mount(index)
    info('starting server on %s:%d' % (config.web_address, config.web_port))
    engine.start()
    engine.block()
Example #6
0
 def start(self, blocking=False):
     """Start the server."""
     obj = DASTestDataService(self.config)  # mount test server
     tree.mount(obj, '/')
     self.engine.start()
     if blocking:
         self.engine.block()
Example #7
0
    def start(self, blocking=True):
        """Configure and start the server."""
        self.configure()
        config['engine'] = engine

        WebSocketPlugin(engine).subscribe()
        cherrypy.tools.websocket = WebSocketTool()
        
        base_url = config.get('ws_base_url', '/websocket')
        wsconfig = {'/ws' :{
                           'tools.websocket.on': True,
                           'tools.websocket.handler_cls': DBSWebSocketHandler
                           }}
        tree.mount(self, base_url, wsconfig) # mount WebSocket service
        obj = DataService()
        tree.mount(obj, '/dbs') # mount another data service
        print "Applications:", pformat(tree.apps)
        print "Configuration:", pformat(self.config)

        pid = PIDFile(engine, self.pid)
        pid.subscribe()

        engine.start()
        print "### number of threads with web engine %s" \
                % threading.active_count()
        if  blocking:
            engine.block()
Example #8
0
 def __init__(self, server, datadir):
   self.lock = Lock()
   self.server = server
   self.datadir = datadir
   if not os.path.exists(datadir):
     os.makedirs(datadir)
   tree.mount(self, script_name=server.baseUrl + "/iguana-snapshot",
              config={"/": {'request.show_tracebacks': False}})
Example #9
0
 def start(self, blocking=True):
     """Configure and start the server."""
     self.configure()
     config = {} # can be something to consider
     obj = WebServerManager(config) # mount the web server manager
     tree.mount(obj, '/')
     engine.start()
     if  blocking:
         engine.block()
Example #10
0
 def register_endpoint(
         self, endpoint_obj: cherryserver.core.endpoint.endpoint.Endpoint):
     conf = self.__default_conf()
     if endpoint_obj.conf:
         conf.update(endpoint_obj.conf)
     path = self.__append_context_path(endpoint_obj)
     self._logger.info(
         "Registering endpoint: {}, final path='{}', final conf='{}'".
         format(endpoint_obj, path, conf))
     tree.mount(endpoint_obj, path, conf)
 def launch_app(app, host="local",port=8080,prefix='/'):
     app.prefix = prefix
     webapp = app.getRoot()
     if host!="local":
         cherrypy.server.socket_host = '0.0.0.1'
     cherrypy.server.socket_port = port
     tree.mount(webapp,prefix)
     if hasattr(engine, "signal_handler"):
         engine.signal_handler.subscribe()
     if hasattr(engine, "console_control_handler"):
         engine.console_control_handler.subscribe()
     engine.start()
     webbrowser.open("http://127.0.0.1:8080")    
     engine.block()
Example #12
0
    def start(self, blocking=True):
        """Configure and start the server."""
        self.configure()
        config = {'db_url':self.config['db_url'],
                  'map_file':self.config['map_file']}
        # can be something to consider
        obj = WebServerManager(config) # mount the web server manager
        if self.config.get('profiler', 0):
            from pyquerybuilder.web.profiler import cachegrind
            cherrypy.tools.cachegrind = cherrypy.Tool('before_handler', \
                    cachegrind, priority=100)
            toolconfig = {'/' : {'tools.cachegrind.on' : True}, }
            tree.mount(obj, '/', toolconfig)
        else:
            tree.mount(obj, '/')

        # mount static document directory
        dirs = self.config['doc_dir'].split('/html')
        doc_config = {'/':
                       { 'tools.staticdir.root': dirs[0],
                         'tools.staticdir.dir': 'html',
                         'tools.staticdir.on': True,}}
        tree.mount(None, '/doc', doc_config)

        engine.start()
        if  blocking:
            engine.block()
Example #13
0
    def start(self, blocking=True):
        """Configure and start the server."""
        self.configure()
        url_base = self.config['web_server']['url_base']
        config = self.config.get('web_server', {})
        config['engine'] = engine
        obj = DASWebService(self.config)
        tree.mount(obj, url_base) # mount web server

        # DBS/Phedex Service
        if  self.config.has_key('dbs_phedex') and \
            self.config['dbs_phedex']['urls']:
            uri  = self.config['mongodb']['dburi']
            urls = {}
            for url in self.config['dbs_phedex']['urls']:
                if  url.find('phedex') != -1:
                    urls['phedex'] = url
                else:
                    urls['dbs'] = url
            expire = self.config['dbs_phedex'].get('expire', 3600)
            obj = DBSPhedexService(uri, urls, expire)
            tree.mount(obj, '/dbs_phedex')
            print "### DAS web server mounted /dbs_phedex service"

        print "### DAS web server, PID=%s, #threads=%s" \
                % (self.pid, threading.active_count())
#        for thr in threading.enumerate():
#            print thr
        print pformat(tree.apps)
        print pformat(self.config)
        pid = PIDFile(engine, self.pid)
        pid.subscribe()
        engine.start()
        print "### number of threads with web engine %s" \
                % threading.active_count()
        if  blocking:
            engine.block()
Example #14
0
import sys
sys.path.insert(0, 'cherrypy.zip')
from cherrypy import tools, config, dispatch, tree

import helpers.decorators
import wsgiref.handlers
from controller.main import Main
from controller.brainstorming_session import BrainstormingSession


#######MAKO###########
tools.mako.collection_size = 500
tools.mako.directories = ["template"]
config["tools.encode.on"] = True
config["tools.encode.encoding"] = "utf-8"

#######ROUTES#########
conf = {
    '/': {
        'request.dispatch': dispatch.MethodDispatcher(),
    }
}
tree.mount(Main(), "/", conf)
tree.mount(BrainstormingSession(), "/session", conf)
wsgiref.handlers.CGIHandler().run(tree)
Example #15
0
def application(env, start_response):
    cfg = {'/': {'foo': 'bar'}}
    app = tree.mount(Root(), script_name='/', config=cfg)
    return tree(env, start_response)