crontab check and restart tomcat on rstudio

This commit is contained in:
Tommaso Piccioli 2019-02-15 15:03:48 +01:00
parent 985867012b
commit bc183931a6
3 changed files with 31 additions and 0 deletions

View File

@ -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"

View File

@ -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

View File

@ -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' ]