Guest User

Untitled

a guest
Dec 3rd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # gunicorn_sr Startup script for gunicorn for sr
  4. #
  5. # chkconfig: - 86 14
  6. # processname: gunicorn
  7. # pidfile:
  8. # description: Python application server
  9. #
  10. ### BEGIN INIT INFO
  11. # Provides: gunicorn_sr
  12. # Required-Start: $local_fs $remote_fs $network
  13. # Required-Stop: $local_fs $remote_fs $network
  14. # Default-Start: 3
  15. # Default-Stop: 0 1 2 4 5 6
  16. # Short-Description: start and stop gunicorn
  17. ### END INIT INFO
  18.  
  19. # Source function library.
  20. . /etc/rc.d/init.d/functions
  21.  
  22. prog=gunicorn
  23. APP_ROOT=/PATH/TO/APP
  24. UNICORN_CONF=$APP_ROOT/gunicorn.py
  25. lockfile=${LOCKFILE-/var/lock/subsys/gunicorn}
  26. pidfile=/var/run/gunicorn_sr.pid
  27. pidfile_old=${pidfile}.oldbin
  28. RETVAL=0
  29. ENV=production
  30.  
  31.  
  32. start() {
  33. echo -n $"Starting $prog: "
  34. cd $APP_ROOT
  35. . /PATH/TO/YOUR/VIRTUALENV/bin/activate
  36. gunicorn --config $UNICORN_CONF --pid $pidfile --daemon --paste ${ENV}.ini
  37. RETVAL=$?
  38. echo -n
  39. [ $RETVAL = 0 ] && echo -e '[\e[32m OK \e[m]'
  40. [ $RETVAL = 0 ] && touch ${lockfile}
  41. return $RETVAL
  42. }
  43.  
  44. stop() {
  45. echo -n $"Stopping $prog: "
  46. killproc -p ${pidfile} ${prog} -QUIT
  47. RETVAL=$?
  48. echo
  49. [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
  50. }
  51.  
  52. restart() {
  53. echo -n $"Restarting $prog: "
  54. killproc -p ${pidfile} ${prog} -USR2
  55. RETVAL=$?
  56. echo
  57. echo -n $"Stopping old $prog: "
  58. killproc -p ${pidfile_old} ${prog} -QUIT
  59. RETVAL=$?
  60. echo
  61. }
  62.  
  63. reload() {
  64. echo -n $"Reloading $prog: "
  65. killproc -p ${pidfile} ${prog} -HUP
  66. RETVAL=$?
  67. echo
  68. }
  69.  
  70. rh_status() {
  71. status -p ${pidfile} ${prog}
  72. }
  73.  
  74. # See how we were called.
  75. case "$1" in
  76. start)
  77. rh_status >/dev/null 2>&1 && exit 0
  78. start
  79. ;;
  80. stop)
  81. stop
  82. ;;
  83. restart)
  84. restart
  85. ;;
  86. reload)
  87. reload
  88. ;;
  89. condrestart|try-restart)
  90. if rh_status >/dev/null 2>&1; then
  91. stop
  92. start
  93. fi
  94. ;;
  95. status)
  96. rh_status
  97. RETVAL=$?
  98. ;;
  99. *)
  100. echo $"Usage: $prog {start|stop|restart|reload|condrestart|try-restart|status|help}"
  101. RETVAL=2
  102. esac
  103.  
  104. exit $RETVAL
Add Comment
Please, Sign In to add comment