aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 471f63e5..3f4f7e81 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 52262b3c..bcc3ac28 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 d1b9c103..33c478ad 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}"