Created
December 2, 2019 09:17
-
-
Save deepakmahakale/b09dbadf805c00955646560d543879c7 to your computer and use it in GitHub Desktop.
A script to restart a node js app and serve over localtunnel (including crontab)
This file contains hidden or 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
# m h dom mon dow command | |
* * * * * /home/deepak/workspace/status_check.sh >> /home/deepak/workspace/logs/status.log 2>&1 |
This file contains hidden or 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 | |
echo "$(date) Killing the processes" | |
kill $(cat pids/run.pid) | |
kill $(cat pids/lt.pid) | |
sleep 3s | |
echo "$(date) Starting the app" | |
/usr/bin/node bot.js > stdout.txt 2> stderr.txt & echo $! > pids/run.pid | |
/usr/local/bin/lt --port 3000 --subdomain english-translated > lt_stdout.txt 2> lt_stderr.txt & echo $! > pids/lt.pid |
This file contains hidden or 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 | |
echo "$(date) Status check - english translated:" | |
if [[ $(ps aux | awk '/[b]in\/lt .*english-translated/ {print $2}') ]]; | |
then | |
echo "$(date) Service is running" | |
else | |
echo "$(date) Service is stopped. Restarting" | |
cd ~/workspace/poc-translate-to-english && sh restart.sh | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment