Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- RED='\033[0;31m'
- NC='\033[0m' # No Color
- printf "I ${RED}love${NC} Github\n "
- # Assumption: PM2 running in cluster mode with atleast 2 instances, Instance ID's: 1, 2 name: api
- echo -e "\n\n1. #################### Reseting Restart counters in PM2"
- pm2 reset api
- PID=1
- echo -e "\n\n2. #################### Restarting PM2 id $PID"
- pm2 reload "$PID"
- pm2 ls
- echo -e "\n\n3. #################### Sleeping for 15 seconds"
- sleep 15s
- echo -e "\n\n4. #################### 15 seconds completed"
- echo -e "\n\n5. Checking process app1(id:$PID) is greacefully reloaded. ?"
- STATUS=$(pm2 describe "$PID" | grep online)
- echo -e "\n\n6. Response from - pm2 describe $PID | grep online"
- echo "$STATUS";
- if [ ! -z "$STATUS" ];
- then
- echo -e "\n\n6. Process not restarting all threads";
- pm2 reload api
- else
- # stoping process if not comes online within 15 seconds
- pm2 stop "$PID";
- echo -e "\n\n${RED}7. Process is not online. release failed${NC}";
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement