Created
March 26, 2019 02:04
-
-
Save IvanWei/9be0f310f130168e2eb449bef7933891 to your computer and use it in GitHub Desktop.
Check app name exist, or not in PM2 (JS)
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 | |
# 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