aboutsummaryrefslogtreecommitdiffstats
path: root/testing/h2o/h2o.initd
blob: 47e301d3349f84e840d2ca730fd3851b5171c0a4 (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
#!/sbin/openrc-run

extra_started_commands="reload"
extra_commands="configtest"
conffile=/etc/h2o.conf
pidfile=/var/run/h2o.pid
command=/usr/bin/h2o
command_args="-c $conffile -m master"

depend() {
	need net
	after sshd
	use dns logger netmount
}

start_pre() {
	configtest || return 1
}

start() {
	ebegin "Starting h2o"
	start-stop-daemon --start \
		--background \
		--pidfile ${pidfile} \
		--exec ${command} \
		-- ${command_args}
	eend $?
}

reload() {
	configtest || return 1
	ebegin "Refreshing h2o configuration"
	kill -HUP `cat $pidfile` &>/dev/null
	eend $? "Failed to reload h2o"
}

configtest() {
	ebegin "Checking h2o configuration"

	if [ ! -f "${conffile}" ]; then
		ewarn "${conffile} does not exist."
		return 1
	fi
}