daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          unicorn
  4. # Required-Start:    $all
  5. # Required-Stop:     $all
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: starts the unicorn app server
  9. # Description:       starts unicorn using start-stop-daemon
  10. ### END INIT INFO
  11. set -e
  12. USAGE="Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
  13. # app settings
  14. USER="ubuntu"
  15. APP_NAME="listpump"
  16. APP_ROOT="/home/$USER/$APP_NAME"
  17. ENV="production"
  18. # environment settings
  19. PATH="/home/$USER/.rbenv/shims:/home/$USER/.rbenv/bin:$PATH"
  20. CMD="cd $APP_ROOT && bundle exec unicorn -c config/unicorn.rb -E $ENV -D"
  21. PID="$APP_ROOT/shared/pids/unicorn.pid"
  22. OLD_PID="$PID.oldbin"
  23. # make sure the app exists
  24. cd $APP_ROOT || exit 1
  25. sig () {
  26.   test -s "$PID" && kill -$1 `cat $PID`
  27. }
  28. oldsig () {
  29.   test -s $OLD_PID && kill -$1 `cat $OLD_PID`
  30. }
  31. case $1 in
  32.   start)
  33.     sig 0 && echo >&2 "Already running" && exit 0
  34.     echo "Starting $APP_NAME in $APP_ROOT"
  35.     su - $USER -c "$CMD"
  36.     ;;
  37.   stop)
  38.     echo "Stopping $APP_NAME"
  39.     sig QUIT && exit 0
  40.     echo >&2 "Not running"
  41.     ;;
  42.   force-stop)
  43.     echo "Force stopping $APP_NAME"
  44.     sig TERM && exit 0
  45.     echo >&2 "Not running"
  46.     ;;
  47.   restart|reload|upgrade)
  48.     sig USR2 && echo "reloaded $APP_NAME" && exit 0
  49.     echo >&2 "Couldn't reload, starting '$CMD' instead"
  50.     $CMD
  51.     ;;
  52.   rotate)
  53.     sig USR1 && echo rotated logs OK && exit 0
  54.     echo >&2 "Couldn't rotate logs" && exit 1
  55.     ;;
  56.   *)
  57.     echo >&2 $USAGE
  58.     exit 1
  59.     ;;
  60. esac
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top