diff --git a/docker/pypi/wmagent-couchdb/Dockerfile b/docker/pypi/wmagent-couchdb/Dockerfile index c1e78dd2a..c4ad566bd 100644 --- a/docker/pypi/wmagent-couchdb/Dockerfile +++ b/docker/pypi/wmagent-couchdb/Dockerfile @@ -11,6 +11,9 @@ RUN apt-get update && apt-get install -y vim less sudo wget unzip python pip # # Install some debugging tools RUN apt-get install -y hostname net-tools iputils-ping procps emacs-nox tcpdump && apt-get clean +# Install recursive ps utility tool +RUN apt-get install -y pslist && apt-get clean + RUN pip install CMSCouchapp ENV COUCH_PORT=5984 diff --git a/docker/pypi/wmagent-couchdb/run.sh b/docker/pypi/wmagent-couchdb/run.sh index 8c3f85e76..55a6e549f 100755 --- a/docker/pypi/wmagent-couchdb/run.sh +++ b/docker/pypi/wmagent-couchdb/run.sh @@ -1,5 +1,26 @@ #!/bin/bash +_service_gracefull_exit() { + ppid=$$ + echo "Full list of currently running processes:" + ps auxf + + echo -e "\nStopping CouchDB" + manage stop + + echo -e "\nList of all child processes of pid $ppid upon agent graceful exit:" + pslist $ppid + + echo -e "\nKilling children proceses recursively" + rkill -9 $ppid + + echo -e "\nFull list of currently running processes after killing children:" + ps auxf +} + +# Trap SIGTERM signal (e.g.: when doing docker stop) +trap _service_gracefull_exit SIGTERM + # Basic initialization for CouchDB thisUser=$(id -un) thisGroup=$(id -gn) @@ -30,7 +51,8 @@ manage start | tee -a $COUCH_LOG_DIR/run.log manage pushapps | tee -a $COUCH_LOG_DIR/run.log echo "start sleeping....zzz" -sleep infinity +sleep infinity & +wait # # start the service # manage start diff --git a/docker/pypi/wmagent-mariadb/Dockerfile b/docker/pypi/wmagent-mariadb/Dockerfile index 245eaf4bd..20b8e15eb 100644 --- a/docker/pypi/wmagent-mariadb/Dockerfile +++ b/docker/pypi/wmagent-mariadb/Dockerfile @@ -7,7 +7,7 @@ ENV MDB_TAG=$MDB_TAG RUN echo MDB_TAG=$MDB_TAG RUN apt-get update && apt-get install -y vim less sudo wget unzip python3 pip \ - hostname net-tools iputils-ping procps emacs-nox tcpdump && apt-get clean + hostname net-tools iputils-ping procps emacs-nox tcpdump pslist && apt-get clean # ENV MDB_PORT= ENV MDB_ROOT_DIR=/data diff --git a/docker/pypi/wmagent-mariadb/run.sh b/docker/pypi/wmagent-mariadb/run.sh index 3dc16e08e..ada07d715 100755 --- a/docker/pypi/wmagent-mariadb/run.sh +++ b/docker/pypi/wmagent-mariadb/run.sh @@ -1,5 +1,26 @@ #!/bin/bash +_service_gracefull_exit() { + ppid=$$ + echo "Full list of currently running processes:" + ps auxf + + echo -e "\nStopping MariaDB" + manage stop-mariadb + + echo -e "\nList of all child processes of pid $ppid upon agent graceful exit:" + pslist $ppid + + echo -e "\nKilling children proceses recursively" + rkill -9 $ppid + + echo -e "\nFull list of currently running processes after killing children:" + ps auxf +} + +# Trap SIGTERM signal (e.g.: when doing docker stop) +trap _service_gracefull_exit SIGTERM + # Basic initialization for MariaDB thisUser=$(id -un) thisGroup=$(id -gn) @@ -28,4 +49,5 @@ manage init-mariadb 2>&1 | tee -a $MDB_LOG_DIR/run.log manage start-mariadb 2>&1 | tee -a $MDB_LOG_DIR/run.log echo "Start sleeping....zzz" -sleep infinity \ No newline at end of file +sleep infinity & +wait