Guest User

Untitled

a guest
Jun 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #!/bin/bash
  2. # This is an sample file, put a copy of this file inside /shared/bin
  3. # I'm assuming a capistrano directory structure under /var/www/my-project/
  4. #
  5. # Called by crontab when the server reboots
  6. #
  7. # To use this file execute with root privileges:
  8. # crontab -e
  9. #
  10. # then add this line:
  11. # @reboot /<full-path-to-project>/shared/bin/server-reboot
  12. #
  13. # Make sure that this is an executable file (chmod 755 my_command).
  14. #
  15. PROJECT_PATH="/var/www/my-project"
  16. PIDS_PATH="$PROJECT_PATH/shared/tmp/pids"
  17. ENV="RAILS_ENV=production"
  18. RVM="/home/webappuser/.rvm/bin/rvm"
  19.  
  20. echo "Restarting 2 resque workers..."
  21.  
  22. function restart_worker {
  23. local PID_FILE="$PIDS_PATH/resque_work_$1.pid"
  24.  
  25. # This will kill any existing pid
  26. if [ -f "$PID_FILE" ]
  27. then
  28. pid=$(cat $PID_FILE)
  29. kill -0 $pid > /dev/null 2>&1
  30. echo "Worker $pid stopped"
  31. rm $PID_FILE
  32. echo "$PID_FILE deleted"
  33. fi
  34.  
  35. # This will start the pid
  36. cd "$PROJECT_PATH/current" && ( $RVM default do bundle exec rake $ENV QUEUE="my_queue" PIDFILE=$PID_FILE BACKGROUND=yes VERBOSE=1 INTERVAL=5 environment resque:work >> /dev/null 2>> /dev/null )
  37. echo "$PID_FILE worker file created"
  38. }
  39.  
  40. # Right now we have 2 workers.
  41. for i in `seq 1 2`;
  42. do
  43. restart_worker $i
  44. done
Add Comment
Please, Sign In to add comment