cp_com 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: FastCGI servers for Django
  4. # Required-Start: networking
  5. # Required-Stop: networking
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: S 0 1 6
  8. # Short-Description: Start FastCGI servers with Django.
  9. # Description: Django, in order to operate with FastCGI, must be started
  10. # in a very specific way with manage.py. This must be done
  11. # for each Django web server that has to run.
  12. ### END INIT INFO
  13. DESC="FastCGI server for castinepatriot.com"
  14. SCRIPTNAME=/var/lib/django/pbp_com/cp_com
  15. . /lib/lsb/init-functions
  16. [ "${NETWORKING}" = "no" ] && exit 0
  17. PIDFILE="/tmp/cp_com.pid"
  18. SOCKET="/tmp/cp_com.sock"
  19. SERVERNAME="cp_com"
  20. METHOD="threaded"
  21. #METHOD="prefork"
  22. DAEMON=/usr/bin/python
  23. DAEMON_OPTS="/var/lib/django/pbp_com/cp_manage.py runfcgi socket=$SOCKET pidfile=$PIDFILE method=$METHOD"
  24. RUN_AS_USER=www-data
  25. stop() {
  26. # kill current fcgi process if it exists
  27. if [ -f $PIDFILE ]; then
  28. echo -n $"Stopping $SERVERNAME..."
  29. kill `cat -- $PIDFILE`
  30. rm -f -- $PIDFILE
  31. fi
  32. }
  33. start() {
  34. if [ ! -f $PIDFILE ]; then
  35. echo -n $"Starting $SERVERNAME..."
  36. start-stop-daemon --start --quiet --user $RUN_AS_USER --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS|| true
  37. chmod a+w $SOCKET
  38. echo
  39. RETVAL=$?
  40. else
  41. echo $"$SERVERNAME is already running."
  42. fi
  43. }
  44. restart() {
  45. if [ -f $PIDFILE ]; then
  46. stop
  47. else
  48. echo "$SERVERNAME not running."
  49. fi
  50. start
  51. }
  52. RETVAL=0
  53. RETVAL=0
  54. case "$1" in
  55. start)
  56. start
  57. ;;
  58. stop)
  59. stop
  60. ;;
  61. restart)
  62. restart
  63. ;;
  64. status)
  65. status_of_proc -p "$PIDFILE" $SERVERNAME && exit 0
  66. RETVAL=$?
  67. ;;
  68. restart)
  69. stop
  70. start
  71. ;;
  72. *)
  73. echo $"Usage: $0 {start|stop|restart|status}"
  74. exit 3
  75. ;;
  76. esac
  77. exit $RETVAL