Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # chkconfig: 345 10 10
  4. # Description: Control Unicorn
  5.  
  6. # Set app name
  7. NAME=""
  8.  
  9. # Tweak yourself
  10. export HOME="/root"
  11. BUNDLE_PATH="/usr/local/bin/bundle"
  12. APP_DIR="/path/to/${NAME}"
  13. PID="/tmp/${NAME}.pid"
  14. CONFIG="${APP_DIR}/config/unicorn.rb"
  15.  
  16. ENV="production"
  17. CMD="${BUNDLE_PATH} exec unicorn -c ${CONFIG} -E ${ENV} -D"
  18.  
  19. start()
  20. {
  21. if [ -e $PID ]; then
  22. echo "${NAME} has already started."
  23. exit 1
  24. fi
  25. echo "Start ${NAME}..."
  26. cd $APP_DIR
  27. $CMD
  28. }
  29.  
  30. stop()
  31. {
  32. if [ ! -e $PID ]; then
  33. echo "${NAME} is not started."
  34. exit 1
  35. fi
  36. echo "Stop ${NAME}..."
  37. kill -QUIT `cat ${PID}`
  38. }
  39.  
  40. force_stop()
  41. {
  42. if [ ! -e $PID ]; then
  43. echo "${NAME} is not started."
  44. exit 1
  45. fi
  46. echo "Force stop ${NAME}..."
  47. kill -INT `cat ${PID}`
  48. }
  49.  
  50. reload()
  51. {
  52. if [ ! -e $PID ]; then
  53. echo "${NAME} is not started."
  54. start
  55. exit 0
  56. fi
  57. echo "Reload ${NAME}..."
  58. kill -HUP `cat ${PID}`
  59. }
  60.  
  61. restart()
  62. {
  63. if [ ! -e $PID ]; then
  64. echo "${NAME} is not started."
  65. start
  66. exit 0
  67. fi
  68. echo "Restart ${NAME}..."
  69. kill -USR2 `cat ${PID}`
  70. }
  71.  
  72. case $1 in
  73. start)
  74. start
  75. ;;
  76. stop)
  77. stop
  78. ;;
  79. force-stop)
  80. force_stop
  81. ;;
  82. reload)
  83. reload
  84. ;;
  85. restart)
  86. restart
  87. ;;
  88. *)
  89. echo "Usage: [start|stop|force-stop|reload|restart]"
  90. ;;
  91. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement