From 505e39ae255875db34d3e030f4176f64e2ff4cc3 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 7 Sep 2016 11:55:15 -0300 Subject: [PATCH 1/8] Added some files configuration in order to get grouper app running --- Dockerfile | 3 +-- container_files/bin/check.sh | 8 ++++---- container_files/bin/cleanup.sh | 12 +++++++++--- container_files/bin/configure.sh | 6 +++--- container_files/bin/main.sh | 3 +-- container_files/bin/start.sh | 17 ++++++++++++++--- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index aea12836..1475796e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ LABEL ImageOS=centos7 LABEL Version=$version ENV VERSION=$version ENV TOMCAT_VERSION="6.0.35" - ENV WAIT_TIME=60 LABEL Build docker build --rm --tag $maintainer/$imagename . @@ -41,4 +40,4 @@ VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs EXPOSE 8080 8009 8005 -CMD ["/opt/bin/start.sh"] \ No newline at end of file +CMD ["/opt/bin/start.sh"] diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index 2b0e354d..2d859e83 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -3,13 +3,13 @@ log="/tmp/grouper.log" echo "Installing schema" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt >> $log echo "Preparing subjects" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -runsqlfile /opt/grouper/2.3.0/subjects.sql -noprompt +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -runsqlfile /opt/grouper/2.3.0/subjects.sql -noprompt >> $log echo "Adding Quickstart data" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt >> $log echo "Checking" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log \ No newline at end of file +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log diff --git a/container_files/bin/cleanup.sh b/container_files/bin/cleanup.sh index a829a2ed..8a9bcb47 100755 --- a/container_files/bin/cleanup.sh +++ b/container_files/bin/cleanup.sh @@ -1,5 +1,11 @@ #!/bin/bash -log="/tmp/grouper.log" - -rm -f /tmp/firsttimerunning >> $log \ No newline at end of file +log="/tmp/grouper-cleanup.log" +date >> $log +if [ -z ${COMPOSE+x} ];then +echo "Not composed so not waiting for MariaDB and first time running was ok: " >> $log +rm -f /tmp/firsttimerunning >> $log +else +echo "Composed with MariaDB, running completed" >> $log +rm -f /tmp/firsttimerunning >> $log +fi diff --git a/container_files/bin/configure.sh b/container_files/bin/configure.sh index 4fc9d922..f092a113 100755 --- a/container_files/bin/configure.sh +++ b/container_files/bin/configure.sh @@ -1,7 +1,7 @@ #!/bin/bash -log="/tmp/grouper.log" - +log="/tmp/grouper-configure.log" +date >> $log #sed -i "s|#GROUPER_SYSTEM_PASSWORD#|$GROUPER_SYSTEM_PASSWORD|g" /opt/etc/grouper.installer.properties >> $log # Long-lived configuration values, these are symlinked into place @@ -24,4 +24,4 @@ sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/etc/grouper.properties >> $lo cat /opt/etc/grouper.hibernate.properties >> $log -cat /opt/etc/grouper.properties >> $log \ No newline at end of file +cat /opt/etc/grouper.properties >> $log diff --git a/container_files/bin/main.sh b/container_files/bin/main.sh index 9a780614..3bda674b 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -log="/tmp/start.log" +log="/tmp/start-main.log" echo "Starting Container: " > $log date >> $log @@ -20,5 +20,4 @@ else echo "Grouper container has run." >> $log echo "If there are problems, docker rm this container and try again." >> $log fi - exit 0 diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index d354de68..d918f9e9 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -1,7 +1,7 @@ #!/bin/bash -log="/tmp/start.log" - +log="/tmp/start-starting.log" +date >> $log if [ -z ${COMPOSE+x} ] then echo "Not composed so not waiting for MariaDB: " > $log @@ -13,11 +13,21 @@ then echo "Not composed non-zero exit status: $laststatus" exit 1 else + echo "Grouper was configured" exit 0 fi else echo "Composed so waiting for MariaDB: " > $log - /opt/wait-for-it/wait-for-it.sh $MYSQL_HOST:3306 -t $WAIT_TIME --strict -- /opt/bin/main.sh + echo "Testing connectivy to database before continue with install" + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;" + laststatus="$?" + while [ "$laststatus" != "0" ]; do + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;" + laststatus="$?" + sleep 5 + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" + done + /opt/bin/main.sh laststatus="$?" echo "Composed status: $laststatus" if [ "$laststatus" != "0" ]; then @@ -25,6 +35,7 @@ else echo "Composed non-zero exit status: $laststatus" exit 1 else + echo "Grouper was configured" exit 0 fi fi From 2482b41759ec382fcd4c16b9123d1d85c1f4b53c Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 7 Sep 2016 12:07:04 -0300 Subject: [PATCH 2/8] Added more log --- container_files/bin/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index 2d859e83..c1738dd1 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -1,6 +1,6 @@ #!/bin/bash -log="/tmp/grouper.log" +log="/tmp/grouper-check.log" echo "Installing schema" >> $log cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt >> $log From 83217208be67e5c36241fd4f64aceff418224233 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 7 Sep 2016 14:48:44 -0300 Subject: [PATCH 3/8] Added apache start --- container_files/bin/check.sh | 2 +- container_files/bin/start.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index c1738dd1..94a3d855 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -1,7 +1,7 @@ #!/bin/bash log="/tmp/grouper-check.log" - +date >> $log echo "Installing schema" >> $log cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt >> $log diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index d918f9e9..6eb2dab6 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -14,7 +14,8 @@ then exit 1 else echo "Grouper was configured" - exit 0 + echo "Starting apache" + /usr/local/bin/httpd-shib-foreground fi else echo "Composed so waiting for MariaDB: " > $log @@ -36,6 +37,7 @@ else exit 1 else echo "Grouper was configured" - exit 0 + echo "Starting apache" + /usr/local/bin/httpd-shib-foreground fi fi From bc0a0ee182b9119199b0f2c20a5acc24f8bb11f6 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 7 Sep 2016 17:04:55 -0300 Subject: [PATCH 4/8] Added more data for dockerfile and supervisord --- Dockerfile | 9 ++++-- container_files/bin/start.sh | 6 ++-- container_files/conf/supervisord.conf | 41 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 container_files/conf/supervisord.conf diff --git a/Dockerfile b/Dockerfile index 1475796e..ab43f183 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,15 +29,20 @@ RUN mkdir -p /opt/grouper/$VERSION \ java-1.8.0-openjdk \ java-1.8.0-openjdk-devel \ MariaDB-client \ + supervisor \ mlocate \ && yum clean all # The installer creates a HSQL DB which we ignore later + +RUN mkdir -p /var/log/supervisor +RUN mv /etc/supervisord.conf /etc/supervisord.conf.old +COPY container_files/conf/supervisord.conf /etc WORKDIR /opt/grouper/$version RUN java -cp :grouperInstaller.jar edu.internet2.middleware.grouperInstaller.GrouperInstaller VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs EXPOSE 8080 8009 8005 - -CMD ["/opt/bin/start.sh"] +CMD ["/usr/bin/supervisord"] +#CMD ["/opt/bin/start.sh"] diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index 6eb2dab6..a97d138d 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -15,7 +15,8 @@ then else echo "Grouper was configured" echo "Starting apache" - /usr/local/bin/httpd-shib-foreground + exit 0 + #/usr/local/bin/httpd-shib-foreground fi else echo "Composed so waiting for MariaDB: " > $log @@ -38,6 +39,7 @@ else else echo "Grouper was configured" echo "Starting apache" - /usr/local/bin/httpd-shib-foreground + exit 0 + #/usr/local/bin/httpd-shib-foreground fi fi diff --git a/container_files/conf/supervisord.conf b/container_files/conf/supervisord.conf new file mode 100644 index 00000000..f487b477 --- /dev/null +++ b/container_files/conf/supervisord.conf @@ -0,0 +1,41 @@ +[supervisord] +logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) +logfile_backups=10 ; (num of main logfile rotation backups;default 10) +loglevel=info ; (log level;default info; others: debug,warn,trace) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=true ; (start in foreground if true;default false) +minfds=1024 ; (min. avail startup file descriptors;default 1024) +minprocs=200 ; (min. avail process descriptors;default 200) +;umask=022 ; (process file creation umask;default 022) +;user=chrism ; (default is current user, required if root) +;identifier=supervisor ; (supervisord identifier, default is 'supervisor') +;directory=/tmp ; (default is not to cd during start) +;nocleanup=true ; (don't clean up tempfiles at start;default false) +;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP) +;environment=KEY=value ; (key value pairs to add to environment) +;strip_ansi=false ; (strip ansi escape codes in logs; def. false) + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket +;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket +;username=chris ; should be same as http_username if set +;password=123 ; should be same as http_password if set +;prompt=mysupervisor ; cmd line prompt (default "supervisor") +;history_file=~/.sc_history ; use readline history if available + + +[program:configure] +command=/bin/bash -c "exec /opt/bin/start.sh" + +[program:apache] +command=/bin/bash -c "exec /usr/local/bin/httpd-shib-foreground" + +[program:tomcat] +command=/bin/bash -c "exec /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run" From b600f3e5dd8b1da00133856366424fd0e657cb39 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Thu, 8 Sep 2016 11:00:17 -0300 Subject: [PATCH 5/8] Added noprompt in order to finish the last check --- container_files/bin/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index 94a3d855..a25581de 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -12,4 +12,4 @@ echo "Adding Quickstart data" >> $log cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt >> $log echo "Checking" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check -noprompt >> $log From 7c93df1b0e5455f7a68f199e13ae6df5b014a0a7 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Thu, 8 Sep 2016 12:11:14 -0300 Subject: [PATCH 6/8] Added some logic.. still testing --- Dockerfile | 3 +-- container_files/bin/apache-grouper.sh | 12 ++++++++++ container_files/bin/tomcat-grouper.sh | 18 +++++++++++++++ container_files/conf/supervisord.conf | 32 +++++++++++++++++++-------- 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 container_files/bin/apache-grouper.sh create mode 100755 container_files/bin/tomcat-grouper.sh diff --git a/Dockerfile b/Dockerfile index ab43f183..96bab613 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,5 @@ RUN java -cp :grouperInstaller.jar edu.internet2.middleware.grouperInstaller.Gro VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs -EXPOSE 8080 8009 8005 +EXPOSE 8080 8009 8005 9001 CMD ["/usr/bin/supervisord"] -#CMD ["/opt/bin/start.sh"] diff --git a/container_files/bin/apache-grouper.sh b/container_files/bin/apache-grouper.sh new file mode 100644 index 00000000..95042b6a --- /dev/null +++ b/container_files/bin/apache-grouper.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +ps auxww |grep -iq start.sh +statusstart=$? + +while [ "$statusstart" != 0 ]; do +ps auxww |grep -iq start.sh +statusstart=$? +echo "First start configuration is in process, please wait" +done +echo "Starting Apache" +/usr/local/bin/httpd-shib-foreground diff --git a/container_files/bin/tomcat-grouper.sh b/container_files/bin/tomcat-grouper.sh new file mode 100755 index 00000000..5ae9fcbb --- /dev/null +++ b/container_files/bin/tomcat-grouper.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +ps auxww |grep -iq start.sh +statusstart=$? +ps auxww | grep -iq bin/httpd-shib-foreground +statusapache=$? + +while [ "$statusstart" != 0 ] && [ "$statusapache" == "0" ]; do +ps auxww |grep -iq start.sh +statusstart=$? +echo "First start configuration is in process, please wait" +ps auxww | grep -iq bin/httpd-shib-foreground +statusapache=$? +echo "Apache is not running, please wait" +done +echo "Starting Tomcat" +/opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run + diff --git a/container_files/conf/supervisord.conf b/container_files/conf/supervisord.conf index f487b477..f3bff527 100644 --- a/container_files/conf/supervisord.conf +++ b/container_files/conf/supervisord.conf @@ -2,7 +2,7 @@ logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) -loglevel=info ; (log level;default info; others: debug,warn,trace) +loglevel=debug ; (log level;default info; others: debug,warn,trace) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=true ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) @@ -23,19 +23,33 @@ minprocs=200 ; (min. avail process descriptors;default 200) supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] -serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket -;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket -;username=chris ; should be same as http_username if set -;password=123 ; should be same as http_password if set -;prompt=mysupervisor ; cmd line prompt (default "supervisor") -;history_file=~/.sc_history ; use readline history if available +;serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket +serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket +username=grouper ; should be same as http_username if set +password=grouper ; should be same as http_password if set +prompt=grouppersupervisor ; cmd line prompt (default "supervisor") +history_file=~/.sc_history ; use readline history if available [program:configure] command=/bin/bash -c "exec /opt/bin/start.sh" +tdout_logfile=/var/log/start_log +stderr_logfile=/var/log/start_log +autorestart=false +autostart=true +priority=1 +startsec=30 [program:apache] -command=/bin/bash -c "exec /usr/local/bin/httpd-shib-foreground" +command=/bin/bash -c "exec /opt/bin/apache-grouper.sh" +autostart=true +autorestart=true +priority=11 + [program:tomcat] -command=/bin/bash -c "exec /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run" +command=/bin/bash -c "exec /opt/bin/tomcat-grouper.sh" +autorestart=true +autostart=true +priority=999 +startsec=10 From c1a61404a8fec051b00b6720987c73a4f75917a1 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Thu, 8 Sep 2016 12:25:22 -0300 Subject: [PATCH 7/8] Added more logic to scripts --- container_files/bin/apache-grouper.sh | 8 +++++--- container_files/bin/check.sh | 2 +- container_files/bin/tomcat-grouper.sh | 10 ++++++---- container_files/conf/supervisord.conf | 8 ++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) mode change 100644 => 100755 container_files/bin/apache-grouper.sh diff --git a/container_files/bin/apache-grouper.sh b/container_files/bin/apache-grouper.sh old mode 100644 new mode 100755 index 95042b6a..08b12c6d --- a/container_files/bin/apache-grouper.sh +++ b/container_files/bin/apache-grouper.sh @@ -1,12 +1,14 @@ #!/bin/bash - +log=/tmp/apache-supervisor.log +date >> $log ps auxww |grep -iq start.sh statusstart=$? while [ "$statusstart" != 0 ]; do ps auxww |grep -iq start.sh statusstart=$? -echo "First start configuration is in process, please wait" +echo "First start configuration is in process, please wait" >> $log done -echo "Starting Apache" +echo "Starting Apache" >> $log +date >> $log /usr/local/bin/httpd-shib-foreground diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index a25581de..77b79c88 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -12,4 +12,4 @@ echo "Adding Quickstart data" >> $log cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt >> $log echo "Checking" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check -noprompt >> $log +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check --noprompt >> $log diff --git a/container_files/bin/tomcat-grouper.sh b/container_files/bin/tomcat-grouper.sh index 5ae9fcbb..77fe2cf0 100755 --- a/container_files/bin/tomcat-grouper.sh +++ b/container_files/bin/tomcat-grouper.sh @@ -1,5 +1,6 @@ #!/bin/bash - +log=/tmp/tomcat-apache-supervisor.log +date >> $log ps auxww |grep -iq start.sh statusstart=$? ps auxww | grep -iq bin/httpd-shib-foreground @@ -8,11 +9,12 @@ statusapache=$? while [ "$statusstart" != 0 ] && [ "$statusapache" == "0" ]; do ps auxww |grep -iq start.sh statusstart=$? -echo "First start configuration is in process, please wait" +echo "First start configuration is in process, please wait" >> $log ps auxww | grep -iq bin/httpd-shib-foreground statusapache=$? -echo "Apache is not running, please wait" +echo "Apache is not running, please wait" >> $log done -echo "Starting Tomcat" +echo "Starting Tomcat" >> $log +date >> $log /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run diff --git a/container_files/conf/supervisord.conf b/container_files/conf/supervisord.conf index f3bff527..979f7e27 100644 --- a/container_files/conf/supervisord.conf +++ b/container_files/conf/supervisord.conf @@ -33,8 +33,8 @@ history_file=~/.sc_history ; use readline history if available [program:configure] command=/bin/bash -c "exec /opt/bin/start.sh" -tdout_logfile=/var/log/start_log -stderr_logfile=/var/log/start_log +tdout_logfile=/var/log/start_supervisor.log +stderr_logfile=/var/log/start_error_supervisor.log autorestart=false autostart=true priority=1 @@ -42,6 +42,8 @@ startsec=30 [program:apache] command=/bin/bash -c "exec /opt/bin/apache-grouper.sh" +tdout_logfile=/var/log/apache_supervisor_log +stderr_logfile=/var/log/apache_error_supervisor_log autostart=true autorestart=true priority=11 @@ -50,6 +52,8 @@ priority=11 [program:tomcat] command=/bin/bash -c "exec /opt/bin/tomcat-grouper.sh" autorestart=true +tdout_logfile=/var/log/tomcat_supervisor_log +stderr_logfile=/var/log/tomcat_error_supervisor_log autostart=true priority=999 startsec=10 From e6cbc624f11c588f9a32f98a7bb17a1df4885086 Mon Sep 17 00:00:00 2001 From: villadalmine Date: Thu, 8 Sep 2016 15:35:09 -0300 Subject: [PATCH 8/8] Removed supervisord --- Dockerfile | 8 +--- container_files/bin/apache-grouper.sh | 14 ------- container_files/bin/main.sh | 2 +- container_files/bin/start.sh | 22 +++++++--- container_files/bin/tomcat-grouper.sh | 20 --------- container_files/conf/supervisord.conf | 59 --------------------------- 6 files changed, 19 insertions(+), 106 deletions(-) delete mode 100755 container_files/bin/apache-grouper.sh delete mode 100755 container_files/bin/tomcat-grouper.sh delete mode 100644 container_files/conf/supervisord.conf diff --git a/Dockerfile b/Dockerfile index 96bab613..7e14e0d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,19 +29,15 @@ RUN mkdir -p /opt/grouper/$VERSION \ java-1.8.0-openjdk \ java-1.8.0-openjdk-devel \ MariaDB-client \ - supervisor \ mlocate \ && yum clean all # The installer creates a HSQL DB which we ignore later -RUN mkdir -p /var/log/supervisor -RUN mv /etc/supervisord.conf /etc/supervisord.conf.old -COPY container_files/conf/supervisord.conf /etc WORKDIR /opt/grouper/$version RUN java -cp :grouperInstaller.jar edu.internet2.middleware.grouperInstaller.GrouperInstaller VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs -EXPOSE 8080 8009 8005 9001 -CMD ["/usr/bin/supervisord"] +EXPOSE 8080 8009 8005 +CMD ["/opt/bin/start.sh"] diff --git a/container_files/bin/apache-grouper.sh b/container_files/bin/apache-grouper.sh deleted file mode 100755 index 08b12c6d..00000000 --- a/container_files/bin/apache-grouper.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -log=/tmp/apache-supervisor.log -date >> $log -ps auxww |grep -iq start.sh -statusstart=$? - -while [ "$statusstart" != 0 ]; do -ps auxww |grep -iq start.sh -statusstart=$? -echo "First start configuration is in process, please wait" >> $log -done -echo "Starting Apache" >> $log -date >> $log -/usr/local/bin/httpd-shib-foreground diff --git a/container_files/bin/main.sh b/container_files/bin/main.sh index 3bda674b..e8c6178c 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -20,4 +20,4 @@ else echo "Grouper container has run." >> $log echo "If there are problems, docker rm this container and try again." >> $log fi -exit 0 +#exit 0 diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index a97d138d..f72508ed 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -13,33 +13,43 @@ then echo "Not composed non-zero exit status: $laststatus" exit 1 else + echo "Grouper was configured" >>$log echo "Grouper was configured" - echo "Starting apache" - exit 0 - #/usr/local/bin/httpd-shib-foreground + echo "Starting tomcat and apache" >>$log + echo "Starting tomcat and apache" + /usr/local/bin/httpd-shib-foreground & + /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run fi else echo "Composed so waiting for MariaDB: " > $log + date >> $log echo "Testing connectivy to database before continue with install" mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;" laststatus="$?" + echo "checking connectivity" >> $log while [ "$laststatus" != "0" ]; do mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;" laststatus="$?" sleep 5 + date >> $log echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" >> $log done /opt/bin/main.sh laststatus="$?" echo "Composed status: $laststatus" + echo "Composed status: $laststatus" >>$log if [ "$laststatus" != "0" ]; then echo "Composed non-zero exit status: $laststatus" >> $log echo "Composed non-zero exit status: $laststatus" exit 1 else + echo "Grouper was configured" >>$log echo "Grouper was configured" - echo "Starting apache" - exit 0 - #/usr/local/bin/httpd-shib-foreground + echo "Starting tomcat and apache" >>$log + echo "Starting tomcat and apache" + date >> $log + /usr/local/bin/httpd-shib-foreground & + /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run fi fi diff --git a/container_files/bin/tomcat-grouper.sh b/container_files/bin/tomcat-grouper.sh deleted file mode 100755 index 77fe2cf0..00000000 --- a/container_files/bin/tomcat-grouper.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -log=/tmp/tomcat-apache-supervisor.log -date >> $log -ps auxww |grep -iq start.sh -statusstart=$? -ps auxww | grep -iq bin/httpd-shib-foreground -statusapache=$? - -while [ "$statusstart" != 0 ] && [ "$statusapache" == "0" ]; do -ps auxww |grep -iq start.sh -statusstart=$? -echo "First start configuration is in process, please wait" >> $log -ps auxww | grep -iq bin/httpd-shib-foreground -statusapache=$? -echo "Apache is not running, please wait" >> $log -done -echo "Starting Tomcat" >> $log -date >> $log -/opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run - diff --git a/container_files/conf/supervisord.conf b/container_files/conf/supervisord.conf deleted file mode 100644 index 979f7e27..00000000 --- a/container_files/conf/supervisord.conf +++ /dev/null @@ -1,59 +0,0 @@ -[supervisord] -logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) -logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) -logfile_backups=10 ; (num of main logfile rotation backups;default 10) -loglevel=debug ; (log level;default info; others: debug,warn,trace) -pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) -nodaemon=true ; (start in foreground if true;default false) -minfds=1024 ; (min. avail startup file descriptors;default 1024) -minprocs=200 ; (min. avail process descriptors;default 200) -;umask=022 ; (process file creation umask;default 022) -;user=chrism ; (default is current user, required if root) -;identifier=supervisor ; (supervisord identifier, default is 'supervisor') -;directory=/tmp ; (default is not to cd during start) -;nocleanup=true ; (don't clean up tempfiles at start;default false) -;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP) -;environment=KEY=value ; (key value pairs to add to environment) -;strip_ansi=false ; (strip ansi escape codes in logs; def. false) - -; the below section must remain in the config file for RPC -; (supervisorctl/web interface) to work, additional interfaces may be -; added by defining them in separate rpcinterface: sections -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[supervisorctl] -;serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket -serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket -username=grouper ; should be same as http_username if set -password=grouper ; should be same as http_password if set -prompt=grouppersupervisor ; cmd line prompt (default "supervisor") -history_file=~/.sc_history ; use readline history if available - - -[program:configure] -command=/bin/bash -c "exec /opt/bin/start.sh" -tdout_logfile=/var/log/start_supervisor.log -stderr_logfile=/var/log/start_error_supervisor.log -autorestart=false -autostart=true -priority=1 -startsec=30 - -[program:apache] -command=/bin/bash -c "exec /opt/bin/apache-grouper.sh" -tdout_logfile=/var/log/apache_supervisor_log -stderr_logfile=/var/log/apache_error_supervisor_log -autostart=true -autorestart=true -priority=11 - - -[program:tomcat] -command=/bin/bash -c "exec /opt/bin/tomcat-grouper.sh" -autorestart=true -tdout_logfile=/var/log/tomcat_supervisor_log -stderr_logfile=/var/log/tomcat_error_supervisor_log -autostart=true -priority=999 -startsec=10