Skip to content

Instantly share code, notes, and snippets.

@erickvasilev
Created May 4, 2017 03:16
Show Gist options
  • Save erickvasilev/cf4af254b9e328687a3b967dc54f666a to your computer and use it in GitHub Desktop.
Save erickvasilev/cf4af254b9e328687a3b967dc54f666a to your computer and use it in GitHub Desktop.
Restart NodeJS App If Down/Crash
#!/bin/bash
pm2 show myapp | grep "stopped"
if [ $? -eq 0 ]; then
printf 'NodeJS App is not running....'
#i use PM2 to manage app
pm2 start myapp
else
printf 'NodeJS App is running'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment