Skip to content

Commit

Permalink
Fix nginx init script.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Sep 26, 2011
1 parent a55e7f4 commit e22d35f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.textile
Expand Up @@ -8,5 +8,5 @@ h2. Include services and Application/Config files location

* Redis (/usr/local/bin/redis, /usr/local/etc/redis.conf)
* MongoDB (/usr/local/bin/mongod, /usr/local/etc/mongodb.conf)
* Nginx (/usr/local/bin/nginx, nginx.conf in /usr/local/nginx/conf)
* Nginx (/usr/local/nginx/sbin/nginx, nginx.conf in /usr/local/nginx/conf)
* PHP-CGI (sudo apt-get install php5-cgi)
1 change: 0 additions & 1 deletion install
Expand Up @@ -8,7 +8,6 @@ sudo mkdir /var/log/mongodb
sudo update-rc.d mongodb defaults

sudo cp nginx /etc/init.d/
sudo mkdir /var/run/nginx
sudo update-rc.d nginx defaults

sudo cp php-cgi /etc/init.d/
Expand Down
19 changes: 12 additions & 7 deletions nginx
Expand Up @@ -11,41 +11,45 @@
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/nginx
PIDFILE=/var/run/nginx/nginx.pid
DAEMON=/usr/local/nginx/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile $PIDFILE \
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;

restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
$PIDFILE --exec $DAEMON
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
$PIDFILE --exec $DAEMON -- $DAEMON_OPTS
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE \
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
Expand All @@ -57,3 +61,4 @@ case "$1" in
esac

exit 0

0 comments on commit e22d35f

Please sign in to comment.