hc
2023-11-20 2e7bd41e4e8ab3d1efdabd9e263a2f7fe79bff8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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