Created
November 9, 2021 18:26
-
-
Save wellington1993/92a98e8b23351d75493ff50ec161a501 to your computer and use it in GitHub Desktop.
Crontab Restart Rails if connection test fail - restart puma, apache, postfix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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