aboutsummaryrefslogtreecommitdiffstats
path: root/testing/nginx-naxsi/nginx.initd
blob: 44c9033b703125a4ac1f7bef097be5525ea03697 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/sbin/openrc-run
supervisor=supervise-daemon

description="Nginx http and reverse proxy server"
extra_started_commands="reload reopen upgrade"

cfgfile=${cfgfile:-/etc/nginx/nginx.conf}
pidfile=/run/nginx/$RC_SVCNAME.sd.pid
command=/usr/sbin/nginx
command_args="-c $cfgfile"
command_args_foreground='-g "daemon off;"'
required_files="$cfgfile"

depend() {
	need net
	use dns logger netmount
}

start_pre() {
	ebegin
	checkpath --directory --owner nginx:nginx ${pidfile%/*}
	$command $command_args -t -q
	eend $?
}

reload() {
	ebegin "Reloading ${SVCNAME} configuration"
	start_pre && $command -s reload
	eend $?
}

reopen() {
	ebegin "Reopening ${SVCNAME} log files"
	$command -s reopen
	eend $?
}

upgrade() {
	restart
}

restart() {
	stop
	# prevents bind() failed (98: Address in use) error msg
	sleep 0.05
	start
}