Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wellington1993/92a98e8b23351d75493ff50ec161a501 to your computer and use it in GitHub Desktop.
Save wellington1993/92a98e8b23351d75493ff50ec161a501 to your computer and use it in GitHub Desktop.
Crontab Restart Rails if connection test fail - restart puma, apache, postfix
#!/bin/bash
curl -sSfL http://lablaudo.com.br/acesso_paciente |egrep "Resultados Online|Senha|Entrar|submit|login" &>/dev/null;
if [ $? != 0 ];then
# Force Kill Apache
killall -9 "/usr/sbin/httpd-prefork" &>/dev/null;
killall -9 "/usr/sbin/httpd-prefork" &>/dev/null;
for x in $(ps auxf |egrep "Ruby|Passenger|passenger|lablaudo|puma|apache2|httpd-prefork" |cut -d' ' -f2 |sort -u | tail -n +2); do kill -9 $x; done
for x in $(ps auxf |egrep "Ruby|Passenger|passenger|lablaudo|puma|apache2|httpd-prefork" |cut -d' ' -f2 |sort -u | tail -n +2); do kill -9 $x; done
apachectl stop
/etc/init.d/passenger-stockfin stop
/etc/init.d/passenger-userscontrol stop
/etc/init.d/puma-lablaudo stop
sleep 2;
# Fix mail
systemctl restart postfix &>/dev/null;
postfix flush; postsuper -d ALL &>/dev/null;
sleep 2;
# Restart Apache
systemctl restart apache &>/dev/null;
apachectl restart &>/dev/null;
systemctl start apache &>/dev/null;
/etc/init.d/puma-lablaudo start
sleep 2;
# Enforce start
systemctl start apache &>/dev/null;
/etc/init.d/passenger-stockfin start ;
/etc/init.d/passenger-userscontrol start ;
/etc/init.d/passenger-stockfin status
/etc/init.d/passenger-userscontrol status
/etc/init.d/puma-lablaudo status
echo "Lablaudo fora do Ar!"
systemctl status apache;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment