Created
February 3, 2012 06:06
-
-
Save masaedw/1728473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon | |
### END INIT INFO | |
# Source function library. | |
. /etc/init.d/functions | |
HOME=/home/passenger | |
PATH="$HOME"/opt/nginx/sbin/nginx:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON="$HOME"/opt/nginx/sbin/nginx | |
PID="$HOME/opt/nginx/logs/nginx.pid" | |
RETVAL=0 | |
test -x "$DAEMON" || exit 5 | |
start() { | |
echo -n $"Starting nginx: " | |
daemon --pidfile="$PID" "$DAEMON" | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Shutting down nginx: " | |
killproc -p "$PID" "$DAEMON" | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
reload() { | |
echo -n "Reloading nginx: " | |
killproc -p "$PID" "$DAEMON" -HUP | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
ngstatus() { | |
status -p "$PID" "$DAEMON" | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|force-reload) | |
stop | |
start | |
;; | |
reload) | |
reload | |
;; | |
status) | |
ngstatus | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2 | |
exit 2 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment