Skip to content

Instantly share code, notes, and snippets.

@hmpmarketing
Created September 24, 2018 17:39
Show Gist options
  • Select an option

  • Save hmpmarketing/4f974d9247351869d09b67c2597a9d1a to your computer and use it in GitHub Desktop.

Select an option

Save hmpmarketing/4f974d9247351869d09b67c2597a9d1a to your computer and use it in GitHub Desktop.
#!/bin/bash
main() {
pm2-docker start ${BOT_NAME}.json &
# Setup signal handler
trap 'sigtermHandler' SIGTERM
sleep 10
while [[ -n "$(pgrep [Pp][Mm]2)" ]]
do
tail -f /dev/null --pid $(pgrep [Pp][Mm]2)
done
}
sigtermHandler() {
echo "SIGTERM Trapped!"
pm2-docker stop all
}
main
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment