From e50e67fbf410b8227ddb67b9fea2dce0c9d16ef1 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 19 Feb 2018 21:33:19 +0100 Subject: [PATCH] +upd metactl.scripts now launches CI for env & web in background (pre-start, killed in post-stop) --- metactl/post-start.sh | 6 +++++- metactl/post-stop.sh | 22 +++++++++++++++++++++- metactl/pre-start.sh | 29 ++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/metactl/post-start.sh b/metactl/post-start.sh index d79c307..bad0dc1 100644 --- a/metactl/post-start.sh +++ b/metactl/post-start.sh @@ -48,7 +48,11 @@ if [ "$DUMP_FILE_EXISTS" = "0" ]; then else - echo "missing"; + ec @echo -n "*** Create trigger............."; + @test ! -d ./virtual/ci && mkdir ./virtual/ci; (exit 0); + @chmod 777 ./virtual/ci; (exit 0); + @touch ./virtual/ci/trigger; echo "done"; + @chmod 777 ./virtual/ci/trigger; (exit 0);ho "missing"; # Create 'persistent' directory if missing test ! -d $ROOT/persistent && mkdir -p $ROOT/persistent; diff --git a/metactl/post-stop.sh b/metactl/post-stop.sh index 3243e0b..22ba604 100644 --- a/metactl/post-stop.sh +++ b/metactl/post-stop.sh @@ -6,4 +6,24 @@ source $(dirname `realpath $0`)/environment.sh; ## ## ## Executed after stopping containers ## ## ## -############################################ \ No newline at end of file +############################################ + +# 1. Stop 'env' spy +echo -ne " * Kill 'env' spy............"; +PID_FILE="$ROOT/ci/env.pid"; +if [ -f $PID_FILE ]; then + kill -9 `cat $PID_FILE` 2>/dev/null && echo "killed" || (echo "fail"; exit 1); +else + echo "already"; +fi; +rm $PID_FILE >/dev/null 2>&1; + +# 2. Stop 'web' spy +echo -ne " * Kill 'web' spy............"; +PID_FILE="$ROOT/ci/web.pid"; +if [ -f $PID_FILE ]; then + kill -9 `cat $PID_FILE` 2>/dev/null && echo "killed" || (echo "fail"; exit 1); +else + echo "already"; +fi; +rm $PID_FILE >/dev/null 2>&1; \ No newline at end of file diff --git a/metactl/pre-start.sh b/metactl/pre-start.sh index 7ae3bf3..807ecfe 100644 --- a/metactl/pre-start.sh +++ b/metactl/pre-start.sh @@ -6,4 +6,31 @@ source $(dirname `realpath $0`)/environment.sh; ## ## ## Executed before launching containers ## ## ## -############################################## \ No newline at end of file +############################################## + +# 1. Create CI folder +echo -ne " * Create CI control folder.."; +test ! -d `dirname $ROOT`/virtual/ci && ( mkdir -p `dirname $ROOT`/virtual/ci && echo "created" || (echo "failed"; exit 1) ) || echo "already"; +chmod o=rx `dirname $ROOT`/virtual/ci; + +# 2. Create 'env' trigger +echo -ne " * Create 'env' trigger......"; +test ! -f `dirname $ROOT`/virtual/ci/env && ( touch `dirname $ROOT`/virtual/ci/env && echo "created" || (echo "failed"; exit 1)) || echo "already"; +chmod o+rwx `dirname $ROOT`/virtual/ci/env; + +# 3. Create 'web' trigger +echo -ne " * Create 'web' trigger......"; +test ! -f `dirname $ROOT`/virtual/ci/web && ( touch `dirname $ROOT`/virtual/ci/web && echo "created" || (echo "failed"; exit 1)) || echo "already"; +chmod o+rwx `dirname $ROOT`/virtual/ci/web; + +# 3. Create 'env' spy +echo -ne " * Launch 'env' spy.........."; +( sh $ROOT/ci/env.sh )& +echo "launched"; +echo -n "$!" > $ROOT/ci/env.pid; + +# 3. Create 'web' spy +echo -ne " * Launch 'web' spy.........."; +( sh $ROOT/ci/web.sh )& +echo "launched"; +echo -n "$!" > $ROOT/ci/web.pid; \ No newline at end of file