Skip to content

Instantly share code, notes, and snippets.

@martiuh
Last active March 22, 2019 18:10
Show Gist options
  • Save martiuh/264e5d738412f4d166810e18ed0ecaf5 to your computer and use it in GitHub Desktop.
Save martiuh/264e5d738412f4d166810e18ed0ecaf5 to your computer and use it in GitHub Desktop.
Check if a node.js app in a shared hosting is still running
APP_PORT=49159
log () {
echo $1 >> /home/hidroval/monitor.log
}
if /usr/bin/netstat -anp | /usr/bin/grep 49154 > /dev/null; then
log "API IS UP"
else
cd /home/hidroval/api/
NODE_ENV=production PORT=$API_PORT nohup /home/hidroval/bin/node . &
log "API WAS DOWN, BUT NOW IS ONLINE"
fi
if netstat -anp | grep 49159 > /dev/null; then
log "APP IS UP"
else
cd /home/hidroval/public_html
NODE_ENV=production PORT=$APP_PORT nohup nohup /home/hidroval/bin/node /home/hidroval/public_html/buildServer/index.js &
log "APP WAS DOWN, BUT IS UP AGAIN"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment