Add start delay to monit for jnlp daemon 15/53115/1
authoragardner <agardner@linuxfoundation.org>
Mon, 5 Mar 2018 17:53:25 +0000 (12:53 -0500)
committeragardner <agardner@linuxfoundation.org>
Mon, 5 Mar 2018 18:06:11 +0000 (13:06 -0500)
delay the first check by 4-minutes
This is a better solution thant check process every 2 cycles
check process every 2 cycles delays initial startup by 2 cycles

delay check gives the script time to spawn, as the wget slave.jar takes
some time from china.

Change-Id: I8066e5b65efc41aaa67ee0f6ab8ee2c1aa86a67c
Signed-off-by: agardner <agardner@linuxfoundation.org>
utils/jenkins-jnlp-connect.sh

index f7c6769..c8a2b49 100755 (executable)
@@ -84,8 +84,14 @@ main () {
 
         if [ -d /etc/monit/conf.d ]; then
             monitconfdir="/etc/monit/conf.d/"
 
         if [ -d /etc/monit/conf.d ]; then
             monitconfdir="/etc/monit/conf.d/"
+            monitconfig="/etc/monit/monitrc"
+            #add start delay
+            sed -i '/^#.* delay /s/^#//' "$monitconfig"
         elif [ -d /etc/monit.d ]; then
             monitconfdir="/etc/monit.d"
         elif [ -d /etc/monit.d ]; then
             monitconfdir="/etc/monit.d"
+            monitconfig="/etc/monitrc"
+            #add start delay
+            sed -i '/^#.* delay /s/^#//' "$monitconfig"
         else
             echo "Could not determine the location of the monit configuration file."
             echo "Make sure monit is installed."
         else
             echo "Could not determine the location of the monit configuration file."
             echo "Make sure monit is installed."
@@ -103,7 +109,7 @@ if does not exist then exec "$mkdir -p /var/run/$jenkinsuser"
 if failed uid $jenkinsuser then exec "$chown $jenkinsuser /var/run/$jenkinsuser"
 if failed gid $jenkinsuser then exec "$chown :$jenkinsuser /var/run/$jenkinsuser"
 
 if failed uid $jenkinsuser then exec "$chown $jenkinsuser /var/run/$jenkinsuser"
 if failed gid $jenkinsuser then exec "$chown :$jenkinsuser /var/run/$jenkinsuser"
 
-check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid every 2 cycles
+check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid
 start program = "/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds"
 stop program = "/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'"
 depends on jenkins_piddir
 start program = "/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds"
 stop program = "/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'"
 depends on jenkins_piddir
@@ -118,7 +124,7 @@ if does not exist then exec \"$mkdir -p /var/run/$jenkinsuser\"
 if failed uid $jenkinsuser then exec \"$chown $jenkinsuser /var/run/$jenkinsuser\"
 if failed gid $jenkinsuser then exec \"$chown :$jenkinsuser /var/run/$jenkinsuser\"
 
 if failed uid $jenkinsuser then exec \"$chown $jenkinsuser /var/run/$jenkinsuser\"
 if failed gid $jenkinsuser then exec \"$chown :$jenkinsuser /var/run/$jenkinsuser\"
 
-check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid every 2 cycles
+check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid
 start program = \"/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds\"
 stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"
 depends on jenkins_piddir\
 start program = \"/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds\"
 stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"
 depends on jenkins_piddir\