From bc183931a6ecc059cfb4c022c19dba3572e62dfa Mon Sep 17 00:00:00 2001 From: "tommaso.piccioli" Date: Fri, 15 Feb 2019 15:03:48 +0100 Subject: [PATCH] crontab check and restart tomcat on rstudio --- rstudio-server/defaults/main.yml | 4 ++++ rstudio-server/files/tomcat_checkandstart | 17 +++++++++++++++++ rstudio-server/tasks/main.yml | 10 ++++++++++ 3 files changed, 31 insertions(+) create mode 100644 rstudio-server/files/tomcat_checkandstart diff --git a/rstudio-server/defaults/main.yml b/rstudio-server/defaults/main.yml index 70f37743..c0ed8a9f 100644 --- a/rstudio-server/defaults/main.yml +++ b/rstudio-server/defaults/main.yml @@ -7,3 +7,7 @@ rstudio_download_url: 'https://download2.rstudio.org/{{ rstudio_file }}' rstudio_install_kill_script: True # cron job minutes rstudio_kill_script_frequency: "*/5" + +rstudio_install_tomcat_checkandstart_script: False +rstudio_install_tomcat_checkandstart_frequency: "*/15" + diff --git a/rstudio-server/files/tomcat_checkandstart b/rstudio-server/files/tomcat_checkandstart new file mode 100644 index 00000000..14f92b0b --- /dev/null +++ b/rstudio-server/files/tomcat_checkandstart @@ -0,0 +1,17 @@ +#!/bin/bash + +ISTOMCATRUNNING=="$(ps -fu gcube | grep -v grep | grep -c java)" + +if (( $ISTOMCATRUNNING == 0 )) +then + sleep 60 + ISTOMCATRUNNING=="$(ps -fu gcube | grep -v grep | grep -c java)" +fi + +if (( $ISTOMCATRUNNING == 0 )) +then + /etc/init.d/tomcat-instance-9000 restart +fi + +exit 0 + diff --git a/rstudio-server/tasks/main.yml b/rstudio-server/tasks/main.yml index de02b9f7..0fecd285 100644 --- a/rstudio-server/tasks/main.yml +++ b/rstudio-server/tasks/main.yml @@ -43,6 +43,16 @@ cron: name="Kill rogue jobs" job="/usr/local/bin/kill-rogue-jobs" user=root minute="{{ rstudio_kill_script_frequency }}" when: rstudio_install_kill_script tags: [ 'rstudio', 'rstudio_server', 'rstudio_kill_rogues' ] + + - name: Install a script that check and restart tomcat + copy: src=tomcat_checkandstart dest=/usr/local/bin/tomcat_checkandstart owner=root group=root mode=0755 + when: rstudio_install_tomcat_checkandstart_script + tags: [ 'rstudio', 'rstudio_server', 'rstudio_tomcat_checkandstart' ] + + - name: Install a cron job that check and restart tomcat + cron: name="Tomcat check and start" job="/usr/local/bin/tomcat_checkandstart" user=root minute="{{ rstudio_tomcat_checkandstart_frequency }}" + when: rstudio_install_tomcat_checkandstart_script + tags: [ 'rstudio', 'rstudio_server', 'rstudio_tomcat_checkandstart' ] when: rstudio_install_server tags: [ 'rstudio', 'rstudio_server' ]