]> git.pld-linux.org Git - packages/nginx.git/blame - nginx.init
- up to 7.5.59 (latest stable)
[packages/nginx.git] / nginx.init
CommitLineData
b9f99299 1#!/bin/sh
2#
3# nginx Nginx Web Server
4#
5# chkconfig: 345 85 15
41247e6d 6# description: Nginx is a World Wide Web server. It is used to serve \
b9f99299 7# HTML files and CGI.
8# processname: nginx
9# pidfile: /var/run/nginx.pid
10# config: /etc/nginx/nginx.conf
11
12
13# Source function library
14. /etc/rc.d/init.d/functions
15
16# Get network config
17. /etc/sysconfig/network
18
19# Get service config
20[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
21
22# Check that networking is up.
23if is_yes "${NETWORKING}"; then
24 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
b9f99299 25 msg_network_down nginx
26 exit 1
27 fi
28else
29 exit 0
30fi
31
32if [ -d "${HTTPD_CONF:-'/etc/nginx/nginx.conf'}" ]; then
33 CFG="-f ${HTTPD_CONF:-'/etc/nginx/nginx.conf'}"
34elif [ -n "$HTTPD_CONF" ]; then
35 echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory"
36 exit 1
37else
38 CFG=""
39fi
40
41247e6d 41start() {
b9f99299 42 # Check if the service is already running?
43 if [ ! -f /var/lock/subsys/nginx ]; then
44 msg_starting nginx
09faaa89 45 daemon /usr/sbin/nginx $CFG $HTTPD_OPTS
b9f99299 46 RETVAL=$?
47 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nginx
48 else
49 msg_already_running nginx
50 fi
41247e6d
ER
51}
52
53stop() {
b9f99299 54 # Stop daemons.
55 if [ -f /var/lock/subsys/nginx ]; then
25abe5ff 56 msg_stopping nginx
b9f99299 57 killproc --waitforname nginx --waitfortime 60 nginx $CFG
58 # Delete pidfile only when nginx was called successfully
59 if [ $? -eq 0 ]; then
41247e6d 60 rm -f /var/lock/subsys/nginx /var/run/nginx.pid >/dev/null 2>&1
b9f99299 61 fi
62 else
63 msg_not_running nginx
64 fi
41247e6d
ER
65}
66
67RETVAL=0
68# See how we were called.
69case "$1" in
70 start)
71 start
72 ;;
73 stop)
74 stop
b9f99299 75 ;;
76 status)
77 status nginx
78 RETVAL=$?
79 ;;
80 restart)
41247e6d
ER
81 stop
82 start
b9f99299 83 ;;
84 reload|force-reload|graceful)
85 if [ -f /var/lock/subsys/nginx ]; then
86 msg_reloading nginx
41247e6d 87 killproc nginx -HUP
b9f99299 88 RETVAL=$?
89 else
41247e6d 90 msg_not_running nginx
b9f99299 91 RETVAL=7
92 fi
93 ;;
94 *)
95 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
96 exit 3
97 ;;
98esac
99
100exit $RETVAL
This page took 0.055811 seconds and 4 git commands to generate.