www-servers/h2o: update init script
authorAkinori Hattori <hattya@gentoo.org>
Wed, 4 Jul 2018 13:19:12 +0000 (22:19 +0900)
committerAkinori Hattori <hattya@gentoo.org>
Wed, 4 Jul 2018 13:23:47 +0000 (22:23 +0900)
Closes: https://bugs.gentoo.org/655468
Package-Manager: Portage-2.3.40, Repoman-2.3.9

www-servers/h2o/files/h2o.initd

index ad598a5f61993453004e309c1dda7ad9305579a0..b100434bd20ee84303f5288d431c94e5096943ae 100644 (file)
@@ -1,51 +1,37 @@
 #!/sbin/openrc-run
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-extra_commands="configtest"
+extra_commands="checkconfig"
 extra_started_commands="reload"
-description="An optimized HTTP/1.x, HTTP/2 server"
-description_configtest="Run H2O' internal config check"
-description_reload="Reload the H2O configuration or upgrade the binary without losing connections"
 
-: ${config:="/etc/h2o/h2o.conf"}
-pidfile=$(grep pid-file "${config}" | cut -d' ' -f2)
+description_checkconfig="Check the configuration file"
+description_reload="Reload the configuration file"
 
+: ${h2o_config:="/etc/${RC_SVCNAME}/${RC_SVCNAME}.conf"}
+
+start_stop_daemon_args="--group ${RC_SVCNAME}"
+command="/usr/bin/${RC_SVCNAME}"
+command_args="-m daemon -c \"${h2o_config}\""
+pidfile="$(grep pid-file "${h2o_config}" | cut -d' ' -f2-)"
 name="H2O"
-command="/usr/bin/h2o"
-command_args="-m daemon -c ${config}"
-required_files="$config"
 
 depend() {
-       use net
-       after logger
+       need net
+       use dns
 }
 
-start_pre() {
-       if [ "${RC_CMD}" != "restart" ]; then
-               configtest || return 1
-       fi
+checkconfig() {
+       "${command}" -m test -c "${h2o_config}" || return 1
 }
 
-stop_pre() {
-       if [ "${RC_CMD}" = "restart" ]; then
-               configtest || return 1
-       fi
+start_pre() {
+       checkconfig || return 1
 }
 
 reload() {
-       configtest || return 1
-       ebegin "Refreshing ${name} configuration"
-       kill -HUP $(cat ${pidfile}) &>/dev/null
-       eend $? "Failed to reload ${name}"
-}
-
-configtest() {
-       ebegin "Checking ${name} configuration"
-
-       if ! ${command} -c ${config} -t &>/dev/null; then
-               ${command} -c ${config} -t
-       fi
-
-       eend $? "Failed, please correct the errors above"
+       checkconfig || return 1
+       ebegin "Reloading ${name:-${RC_SVCNAME}}"
+       start-stop-daemon --signal HUP --pidfile "${pidfile}"
+       eend ${?}
 }