From fc99a34956e459c358f6803a1a816ad74c64b6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 3 Apr 2015 14:55:46 -0400 Subject: [PATCH] Make up now starts a development environment Change-Id: I96549e4a6af70c9f90d3bf3d375f9ed59e636b1e --- Dockerfile | 9 +++----- doc/source/getting_started.rst | 3 +++ fig.yml | 2 ++ requirements.txt | 1 + surveil/cmd/api.py | 38 +++++----------------------------- 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index d76aa1b..50c672f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,23 +12,18 @@ RUN pip install python-surveilclient # Download packs RUN apt-get install -y subversion && \ - ## Packs svn checkout https://github.com/savoirfairelinux/monitoring-tools/trunk/packs/generic-host /packs/generic-host && \ svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/packs/linux-glance /packs/linux-glance && \ svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/packs/linux-keystone /packs/linux-keystone && \ apt-get remove -y subversion -# Copy files -ADD surveil /surveil/surveil -ADD setup.cfg /surveil/setup.cfg ADD requirements.txt surveil/requirements.txt ADD setup.py /surveil/setup.py +ADD setup.cfg /surveil/setup.cfg ADD .git /surveil/.git -ADD README.rst surveil/README.rst # Install RUN pip install -r /surveil/requirements.txt -RUN cd surveil && python setup.py install # Supervisor ADD tools/docker/surveil_container/etc/supervisor /etc/supervisor @@ -37,4 +32,6 @@ ADD tools/docker/surveil_container/etc/supervisor /etc/supervisor EXPOSE 8080 CMD sleep 20 && \ + cd /surveil/ && \ + python setup.py develop && \ /usr/bin/supervisord diff --git a/doc/source/getting_started.rst b/doc/source/getting_started.rst index 66318a1..ec8345e 100644 --- a/doc/source/getting_started.rst +++ b/doc/source/getting_started.rst @@ -17,3 +17,6 @@ at the root of the repository with commands to make it easier to use: Configuration for the different services running in the Docker container are stored in tools/docker. + +Surveil container mounts your local project folder and pecan reloads every +time the project files change thus providing a proper development environment. diff --git a/fig.yml b/fig.yml index 9e2e716..d8ed008 100644 --- a/fig.yml +++ b/fig.yml @@ -6,6 +6,8 @@ surveil: - shinken ports: - "8080:8080" + volumes: + - ./surveil/:/surveil/ shinken: build: tools/docker/shinken_container/ diff --git a/requirements.txt b/requirements.txt index 1aa4098..fdd7db3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ pecan>=0.5.0 pymongo>=2.7.2 wsme requests +watchdog diff --git a/surveil/cmd/api.py b/surveil/cmd/api.py index 2b711e5..a99a671 100644 --- a/surveil/cmd/api.py +++ b/surveil/cmd/api.py @@ -15,41 +15,13 @@ """Starter script for the Surveil API service.""" import os -from wsgiref import simple_server - -import pecan +import subprocess +import sys from surveil import api -from surveil.api import app as api_app - - -# TODO(aviau): Load conf from oslo -def get_pecan_config(): - # Set up the pecan configuration - filename = os.path.join(os.path.dirname(api.__file__), "config.py") - return pecan.configuration.conf_from_file(filename) def main(): - cfg = get_pecan_config() - - app = api_app.setup_app(cfg) - - # Create the WSGI server and start it - host, port = cfg.server.host, cfg.server.port - srv = simple_server.make_server(host, port, app) - - # TODO(aviau): Logging. don't print :o) - print ('Starting server in PID %s' % os.getpid()) - - if host == '0.0.0.0': - print ( - 'serving on 0.0.0.0:%(port)s, view at http://127.0.0.1:%(port)s' % - dict(port=port) - ) - else: - print ( - 'serving on http://%(host)s:%(port)s' % dict(host=host, port=port) - ) - - srv.serve_forever() + filename = os.path.join(os.path.dirname(api.__file__), "config.py") + subprocess.Popen(['pecan', 'serve', '--reload', filename], + stdin=sys.stdout, stdout=sys.stdout)