You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2015/11/12 18:28:12 UTC

[11/13] marmotta git commit: MARMOTTA-588: switched to an entrypoint to have more control about the container lifecycle

MARMOTTA-588: switched to an entrypoint to have more control about the container lifecycle


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/f47d2142
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/f47d2142
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/f47d2142

Branch: refs/heads/develop
Commit: f47d21421ec007bc2f7ca0df772c3b306e6fdecf
Parents: 940cac1
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Nov 12 18:07:12 2015 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Nov 12 18:07:12 2015 +0100

----------------------------------------------------------------------
 launchers/marmotta-webapp/Dockerfile            |  4 +---
 .../marmotta-webapp/src/docker/entrypoint.sh    | 23 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/f47d2142/launchers/marmotta-webapp/Dockerfile
----------------------------------------------------------------------
diff --git a/launchers/marmotta-webapp/Dockerfile b/launchers/marmotta-webapp/Dockerfile
index 26713a8..f89585c 100644
--- a/launchers/marmotta-webapp/Dockerfile
+++ b/launchers/marmotta-webapp/Dockerfile
@@ -68,7 +68,5 @@ RUN chown -R tomcat7:tomcat7 "$(dirname $CONF_PATH)"
 #RUN mvn clean
 RUN apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
 
-CMD service postgresql start; \
-    service tomcat7 start; \
-	tail -f /var/log/tomcat7/catalina.out
+ENTRYPOINT ["/marmotta-webapp/src/docker/entrypoint.sh"]
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/f47d2142/launchers/marmotta-webapp/src/docker/entrypoint.sh
----------------------------------------------------------------------
diff --git a/launchers/marmotta-webapp/src/docker/entrypoint.sh b/launchers/marmotta-webapp/src/docker/entrypoint.sh
new file mode 100755
index 0000000..2769a28
--- /dev/null
+++ b/launchers/marmotta-webapp/src/docker/entrypoint.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+# SIGTERM-handler
+sigterm_handler() {
+  service tomcat7 stop
+  service postgresql stop
+  exit 143; # 128 + 15 -- SIGTERM
+}
+
+# setup handlers on callback
+# kill the last background process (tail) and execute the custom handler
+trap 'kill ${!}; sigterm_handler' SIGTERM
+
+# run application
+service postgresql start
+service tomcat7 start
+
+# wait indefinetely
+while true
+do
+  tail -f /var/log/tomcat7/catalina.out & wait ${!}
+done
+