s6 supervisor fixes
Add the ability to force-kill a service if it does not go down successfully. Also, adjust the default wait time for an s6 service to go down to 60 seconds.
This commit is contained in:
parent
318e873481
commit
e805c74d31
@ -111,9 +111,12 @@ The path to the s6 service directory if you are monitoring this service
|
||||
with S6. The default is /var/svc.d/${RC_SVCNAME}.
|
||||
.It Ar s6_svwait_options_start
|
||||
The options to pass to s6-svwait when starting the service via s6.
|
||||
.It Ar s6_force_kill
|
||||
Should we force-kill this service if s6_service_timeout_stop expires
|
||||
but the service doesn't go down during shutdown? The default is yes.
|
||||
.It Ar s6_service_timeout_stop
|
||||
The amount of time, in milliseconds, s6-svc should wait for the service
|
||||
to go down when stopping the service. The default is 10000.
|
||||
to go down when stopping the service. The default is 60000.
|
||||
.It Ar start_stop_daemon_args
|
||||
List of arguments passed to start-stop-daemon when starting the daemon.
|
||||
.It Ar command
|
||||
|
@ -39,6 +39,10 @@ s6_service_path - the path to the s6 service directory. The default is
|
||||
s6_svwait_options_start - the options to pass to s6-svwait when starting
|
||||
the service. If this is not set, s6-svwait will not be called.
|
||||
|
||||
s6_force_kill - Should we try to force kill this service if the
|
||||
s6_service_timeout_stop timeout expires when shutting down this service?
|
||||
The default is yes.
|
||||
|
||||
s6_service_timeout_stop - the amount of time, in milliseconds, s6-svc
|
||||
should wait for a service to go down when stopping.
|
||||
|
||||
|
20
sh/s6.sh
20
sh/s6.sh
@ -12,6 +12,20 @@
|
||||
|
||||
[ -z "${s6_service_path}" ] && s6_service_path="/var/svc.d/${RC_SVCNAME}"
|
||||
|
||||
_s6_force_kill() {
|
||||
local pid
|
||||
s6_service_link="${RC_SVCDIR}/s6-scan/${s6_service_path##*/}"
|
||||
pid="${3%)}"
|
||||
[ -z "${pid}" ] && return 0
|
||||
if kill -0 "${pid}" 2> /dev/null; then
|
||||
ewarn "Sending DOWN & KILL for ${RC_SVCNAME}"
|
||||
s6-svc -dk "${s6_service_link}"
|
||||
sleep 1
|
||||
kill -0 "${pid}" 2>/dev/null && return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
s6_start()
|
||||
{
|
||||
if [ ! -d "${s6_service_path}" ]; then
|
||||
@ -41,7 +55,11 @@ s6_stop()
|
||||
fi
|
||||
s6_service_link="${RC_SVCDIR}/s6-scan/${s6_service_path##*/}"
|
||||
ebegin "Stopping ${name:-$RC_SVCNAME}"
|
||||
s6-svc -wD -d -T ${s6_service_timeout_stop:-10000} "${s6_service_link}"
|
||||
s6-svc -d -wD -T ${s6_service_timeout_stop:-60000} "${s6_service_link}"
|
||||
set -- $(s6-svstat "${s6_service_link}")
|
||||
[ "$1" = "up" ] &&
|
||||
yesno "${s6_force_kill:-yes}" &&
|
||||
_s6_force_kill "$@"
|
||||
set -- $(s6-svstat "${s6_service_link}")
|
||||
[ "$1" = "down" ]
|
||||
eend $? "Failed to stop ${name:-$RC_SVCNAME}"
|
||||
|
Loading…
Reference in New Issue
Block a user