Advertisement
Guest User

Debian ChiliProject daemon

a guest
Nov 14th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.78 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:             chiliproject
  4. # Required-Start:       $local_fs $remote_fs $network $syslog
  5. # Required-Stop:        $local_fs $remote_fs $network $syslog
  6. # Should-Start:         $network
  7. # Should-Stop:          $network
  8. # Default-Start:        2 3 4 5
  9. # Default-Stop:         0 1 6
  10. # Short-Description:    Daemonized version of chiliproject
  11. # Description:          Starts the chiliproject daemon
  12. #                       /etc/default/chiliproject.
  13. ### END INIT INFO
  14.  
  15. # Get lsb functions
  16. . /lib/lsb/init-functions
  17.  
  18. RAILS_ENV=production
  19. CHILIPROJECT_DIR=/srv/chiliproject/chiliproject
  20. CHILIPROJECT_ADDRESS=localhost
  21. CHILIPROJECT_PORT=3000
  22. CHILIPROJECT_USER=chiliproject
  23. CHILIPROJECT_GROUP=chiliproject
  24. CHILIPROJECT_PIDFILE=${CHILIPROJECT_DIR}/tmp/pids/server.pid
  25.  
  26. case "$1" in
  27.   start)
  28.     log_begin_msg "Starting Chili Project"
  29.     cd "${CHILIPROJECT_DIR}"
  30.     start-stop-daemon --make-pidfile \
  31.                       --background \
  32.                       --start --quiet \
  33.                       --pidfile "${CHILIPROJECT_PIDFILE}" \
  34.                       --user "${CHILIPROJECT_USER}" \
  35.                       --exec /usr/bin/ruby "${CHILIPROJECT_DIR}"/script/server -- \
  36.                       --daemon --environment=${RAILS_ENV} \
  37.                       --binding=${CHILIPROJECT_ADDRESS} --port=${CHILIPROJECT_PORT} \
  38.                       ${CHILIPROJECT_OPTS}
  39.     log_end_msg $?
  40.     ;;  
  41.   restart)
  42.     $0 stop
  43.     sleep 1
  44.     $0 start
  45.     ;;  
  46.   stop)
  47.     log_begin_msg "Stopping Chili Project"
  48.     cd "${CHILIPROJECT_DIR}"
  49.     start-stop-daemon --stop --signal INT --quiet --pidfile "${CHILIPROJECT_PIDFILE}"
  50.     log_end_msg $?
  51.   ;;  
  52.   *)  
  53.     log_success_msg "Usage: /etc/init.d/chiliproject {start|stop|restart}"
  54.     exit 1
  55. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement