Skip to content

Instantly share code, notes, and snippets.

@IvanWei
Created March 26, 2019 02:04
Show Gist options
  • Save IvanWei/9be0f310f130168e2eb449bef7933891 to your computer and use it in GitHub Desktop.
Save IvanWei/9be0f310f130168e2eb449bef7933891 to your computer and use it in GitHub Desktop.
Check app name exist, or not in PM2 (JS)
#!/bin/bash
# Set App name
APP_NAME=node_server
# Get information by app name with pm2
pm2 describe $APP_NAME > /dev/null
# Save data of previous shell to here
IS_EXIST_BY_APP_NAME=$?
if [ "${IS_EXIST_BY_APP_NAME}" -ne 0 ]; then
pm2 start [do the write thing] --name=$APP_NAME
else
pm2 restart $APP_NAME
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment