From 550cdd19e353d3a6f555998a71c27d364bafbcae Mon Sep 17 00:00:00 2001 From: Cyprien DIOT Date: Thu, 27 Aug 2015 16:11:34 +0200 Subject: [PATCH] Adding trigger in dev_demoinstance launcher to fix ownership Fixes #8 --- docker-compose.yml | 5 ++-- frontend/dev_gulp | 4 ---- ressources/dev_demoinstance | 23 ++++++++++++++----- ressources/dev_demoinstance.py | 10 ++++++++ ressources/supervisor_dev/backend.conf | 10 ++++++++ .../dev.conf => supervisor_dev/frontend.conf} | 6 +++++ 6 files changed, 46 insertions(+), 12 deletions(-) mode change 100644 => 100755 ressources/dev_demoinstance create mode 100644 ressources/dev_demoinstance.py create mode 100644 ressources/supervisor_dev/backend.conf rename ressources/{supervisor/dev.conf => supervisor_dev/frontend.conf} (57%) diff --git a/docker-compose.yml b/docker-compose.yml index 2cf39e6..75d1542 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,9 @@ demoinstance: - ./backend/demoinstance/:/opt/demoinstance/backend/demoinstance/ - ./frontend/:/opt/demoinstance/frontend/ - ./config/:/etc/demoinstance/ - - ./ressources/supervisor:/etc/supervisor/conf.d - - ./ressources/dev_demoinstance:/usr/local/bin/demoinstance + - ./ressources/supervisor_dev:/etc/supervisor/conf.d + - ./ressources/dev_demoinstance:/opt/demoinstance/dev_demoinstance + - ./ressources/dev_demoinstance.py:/opt/demoinstance/dev_demoinstance.py ports: - "8080:8080" expose: diff --git a/frontend/dev_gulp b/frontend/dev_gulp index 973fcff..16b658c 100644 --- a/frontend/dev_gulp +++ b/frontend/dev_gulp @@ -10,10 +10,6 @@ function finish { cd /opt/demoinstance/frontend chown -R `stat -c "%u:%g" .` . fi - if [ -d "/opt/demoinstance/backend" ]; then - cd /opt/demoinstance/backend - chown -R `stat -c "%u:%g" .` . - fi } diff --git a/ressources/dev_demoinstance b/ressources/dev_demoinstance old mode 100644 new mode 100755 index 525a72c..dc2e221 --- a/ressources/dev_demoinstance +++ b/ressources/dev_demoinstance @@ -1,9 +1,20 @@ -#!/usr/bin/python +#!/bin/bash -import sys +set -o errexit +set -o pipefail +set -o nounset -sys.path.insert(1, "/opt/demoinstance/backend/") -from demoinstance.cli import cli_entrypoint -print "DemoInstance Dev Environment" -cli_entrypoint() +function finish { + echo "Fixing file permissions: it might take some time" + if [ -d "/opt/demoinstance/backend/demoinstance" ]; then + cd /opt/demoinstance/backend/demoinstance + chown -R `stat -c "%u:%g" .` . + fi +} + + +trap finish EXIT + + +python2 /opt/demoinstance/dev_demoinstance.py $@ \ No newline at end of file diff --git a/ressources/dev_demoinstance.py b/ressources/dev_demoinstance.py new file mode 100644 index 0000000..ff60708 --- /dev/null +++ b/ressources/dev_demoinstance.py @@ -0,0 +1,10 @@ +#!/usr/bin/python + +import sys + +sys.path.insert(1, "/opt/demoinstance/backend/") + +from demoinstance.cli import cli_entrypoint +print "DemoInstance Dev Environment" +cli_entrypoint() + diff --git a/ressources/supervisor_dev/backend.conf b/ressources/supervisor_dev/backend.conf new file mode 100644 index 0000000..3c02b51 --- /dev/null +++ b/ressources/supervisor_dev/backend.conf @@ -0,0 +1,10 @@ +[supervisord] +nodaemon=true + +[program:backend] +command=bash /opt/demoinstance/dev_demoinstance -c /etc/demoinstance/config.ini +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + diff --git a/ressources/supervisor/dev.conf b/ressources/supervisor_dev/frontend.conf similarity index 57% rename from ressources/supervisor/dev.conf rename to ressources/supervisor_dev/frontend.conf index cd5d120..5a01a95 100644 --- a/ressources/supervisor/dev.conf +++ b/ressources/supervisor_dev/frontend.conf @@ -6,3 +6,9 @@ stdout_logfile_maxbytes=0 stderr_logfile=/dev/fd/2 stderr_logfile_maxbytes=0 +[program:nginx] +command=nginx -g "daemon off;" +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0