Created
November 3, 2010 14:01
-
-
Save jcxplorer/661106 to your computer and use it in GitHub Desktop.
Nginx init script for Ubuntu with Passenger.
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: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using its daemon | |
### END INIT INFO | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/nginx/sbin | |
DAEMON=/opt/nginx/sbin/nginx | |
NAME=nginx | |
PIDFILE=/var/run/nginx.pid | |
test -x $DAEMON || exit 0 | |
set -e | |
. /lib/lsb/init-functions | |
test_nginx_config() { | |
if $DAEMON -t $DAEMON_OPTS | |
then | |
return 0 | |
else | |
return $? | |
fi | |
} | |
case "$1" in | |
start) | |
echo -n "Starting $NAME: " | |
test_nginx_config | |
$DAEMON | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $NAME: " | |
$DAEMON -s stop | |
echo "$NAME." | |
;; | |
restart) | |
echo -n "Restarting $NAME: " | |
$DAEMON -s stop | |
sleep 1 | |
test_nginx_config | |
$DAEMON | |
echo "$NAME." | |
;; | |
reload) | |
echo -n "Reloading $NAME configuration: " | |
test_nginx_config | |
$DAEMON -s reload | |
echo "$NAME." | |
;; | |
configtest) | |
echo -n "Testing $NAME configuration: " | |
if test_nginx_config | |
then | |
echo "$NAME." | |
else | |
exit $? | |
fi | |
;; | |
status) | |
status_of_proc -p $PIDFILE "$DAEMON" nginx && exit 0 || exit $? | |
;; | |
*) | |
echo "Usage: $NAME {start|stop|restart|reload|status|configtest}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment