kumquat-buildroot/package/nginx/S50nginx
Thomas Claveirole 99b8044a67 package/nginx/S50nginx: Do not assume start-stop-daemon knows -R.
start-stop-daemon fails on -R when not compiled with
CONFIG_FEATURE_START_STOP_DAEMON_FANCY.  Thus, do not rely on -R
during stop to avoid a race condition during restart.

Use a sleep 1 during restart instead, as suggested by Peter Korsgaard
in <87bmluk4bm.fsf@dell.be.48ers.dk>.

Signed-off-by: Thomas Claveirole <thomas.claveirole@green-communications.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2017-10-10 17:51:02 +02:00

32 lines
584 B
Bash
Executable File

#!/bin/sh
#
# Start/stop nginx
#
NGINX=/usr/sbin/nginx
PIDFILE=/var/run/nginx.pid
case "$1" in
start)
echo "Starting nginx..."
mkdir -p /var/log/nginx /var/tmp/nginx
start-stop-daemon -S -x "$NGINX" -p "$PIDFILE"
;;
stop)
echo "Stopping nginx..."
start-stop-daemon -K -x "$NGINX" -p "$PIDFILE" -o
;;
reload|force-reload)
echo "Reloading nginx configuration..."
"$NGINX" -s reload
;;
restart)
"$0" stop
sleep 1 # Prevent race condition: ensure nginx stops before start.
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac