aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2017-11-16 15:35:35 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-11-16 15:35:35 -0600
commite805c74d31113c75058d860588e83bca120decf6 (patch)
tree28aba9bddc93cf4a205bd769d3fc4991446873a0
parentstrongly encourage Linux users to not make /etc/mtab a flat file (diff)
downloadopenrc-master.zip
openrc-master.tar.gz
openrc-master.tar.bz2
s6 supervisor fixesHEADmaster
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.
-rw-r--r--man/openrc-run.85
-rw-r--r--s6-guide.md4
-rw-r--r--sh/s6.sh20
3 files changed, 27 insertions, 2 deletions
diff --git a/man/openrc-run.8 b/man/openrc-run.8
index 471f63e..3f4f7e8 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -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
diff --git a/s6-guide.md b/s6-guide.md
index 52262b3..bcc3ac2 100644
--- a/s6-guide.md
+++ b/s6-guide.md
@@ -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.
diff --git a/sh/s6.sh b/sh/s6.sh
index d1b9c10..33c478a 100644
--- a/sh/s6.sh
+++ b/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}"