Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #!/bin/bash
  2. RED='\033[0;31m'
  3. NC='\033[0m' # No Color
  4. printf "I ${RED}love${NC} Github\n "
  5. # Assumption: PM2 running in cluster mode with atleast 2 instances, Instance ID's: 1, 2 name: api
  6.  
  7. echo -e "\n\n1. #################### Reseting Restart counters in PM2"
  8. pm2 reset api
  9.  
  10. PID=1
  11. echo -e "\n\n2. #################### Restarting PM2 id $PID"
  12. pm2 reload "$PID"
  13.  
  14. pm2 ls
  15.  
  16. echo -e "\n\n3. #################### Sleeping for 15 seconds"
  17. sleep 15s
  18. echo -e "\n\n4. #################### 15 seconds completed"
  19.  
  20. echo -e "\n\n5. Checking process app1(id:$PID) is greacefully reloaded. ?"
  21. STATUS=$(pm2 describe "$PID" | grep online)
  22.  
  23. echo -e "\n\n6. Response from - pm2 describe $PID | grep online"
  24. echo "$STATUS";
  25.  
  26. if [ ! -z "$STATUS" ];
  27. then
  28. echo -e "\n\n6. Process not restarting all threads";
  29. pm2 reload api
  30. else
  31. # stoping process if not comes online within 15 seconds
  32. pm2 stop "$PID";
  33. echo -e "\n\n${RED}7. Process is not online. release failed${NC}";
  34. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement