diff --git a/Dockerfile b/Dockerfile index e48e6c5..2d5189c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,12 +45,18 @@ RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux- # required for python-prctl RUN apt-get update && apt-get install -y libcap-dev && rm -rf /var/lib/apt/lists/* - -ADD . /app/ RUN pip3 install virtualenv \ && virtualenv --always-copy /app/env \ && /app/env/bin/pip3 install paver + +# install requirements.txt stuff in an earlier layer +# this is just to speed up local builds in dev +ADD requirements.txt /app/ +RUN /app/env/bin/pip3 install -r requirements.txt + +ADD . /app/ RUN /app/env/bin/paver install_deps CMD /app/env/bin/python3 /app/sideboard/run_server.py EXPOSE 8282 + diff --git a/development-defaults.ini b/development-defaults.ini index eb39f37..a28b880 100644 --- a/development-defaults.ini +++ b/development-defaults.ini @@ -3,6 +3,8 @@ ws.auth_required = False [cherrypy] server.socket_host = "0.0.0.0" +server.socket_port = "8282" +server.thread_pool = "30" engine.autoreload.on = True tools.cpstats.on = False diff --git a/sideboard/configspec.ini b/sideboard/configspec.ini index 927176c..4f05f5d 100644 --- a/sideboard/configspec.ini +++ b/sideboard/configspec.ini @@ -121,6 +121,7 @@ profiling.strip_dirs = boolean(default=False) server.socket_host = string(default="127.0.0.1") server.socket_port = integer(default=8282) +server.thread_pool = integer(default=30) tools.reset_threadlocal.on = boolean(default=True) diff --git a/sideboard/run_server.py b/sideboard/run_server.py index acfa874..91534d6 100644 --- a/sideboard/run_server.py +++ b/sideboard/run_server.py @@ -5,5 +5,6 @@ import sideboard.server if __name__ == '__main__': + # Start the server engine (Option 1 *and* 2) cherrypy.engine.start() cherrypy.engine.block() diff --git a/sideboard/server.py b/sideboard/server.py index 08f1693..38f914d 100755 --- a/sideboard/server.py +++ b/sideboard/server.py @@ -143,6 +143,7 @@ def check_authentication(cls): 'tools.staticdir.dir': os.path.join(config['module_root'], 'docs', 'html'), 'tools.staticdir.index': 'index.html' } + cherrypy_config = {} for setting, value in config['cherrypy'].items(): if isinstance(value, six.string_types): @@ -155,6 +156,19 @@ def check_authentication(cls): cherrypy_config[setting] = value cherrypy.config.update(cherrypy_config) +# Unsubscribe the default server +cherrypy.server.unsubscribe() + +# Instantiate a new server object +server = cherrypy._cpserver.Server() + +# Configure the server object +server.socket_host = config['cherrypy']['server.socket_host'] +server.socket_port = config['cherrypy']['server.socket_port'] +server.thread_pool = config['cherrypy']['server.thread_pool'] + +# Subscribe this server +server.subscribe() # on Python 2, we need bytestrings for CherryPy config, see https://bitbucket.org/cherrypy/cherrypy/issue/1184 def recursive_coerce(d):