mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-13 20:08:05 +08:00
⛄ Sync 2026-11-01 05:43:29
This commit is contained in:
1 parent
fae68afc83
commit
d1e51134a0
187 files changed
+3752
-2114
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=dockerd
|
||||
PKG_FLAGS:=hold
|
||||
PKG_VERSION:=27.3.1
|
||||
PKG_RELEASE:=6
|
||||
PKG_RELEASE:=8
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
|
||||
@@ -223,6 +223,8 @@ start_service() {
|
||||
procd_set_param command /usr/bin/dockerd --config-file="${DOCKERD_CONF}"
|
||||
fi
|
||||
procd_set_param limits nofile="${nofile} ${nofile}"
|
||||
# Give dockerd the time to stop the containers before it gets killed
|
||||
procd_set_param term_timeout 300
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
@@ -286,8 +288,50 @@ iptables_add_blocking_rule() {
|
||||
config_list_foreach "${cfg}" blocked_interfaces handle_iptables_rule "${device}" "${extra_iptables_args}"
|
||||
}
|
||||
|
||||
# Read procd's notifications until one contains the given text, or none comes for the given seconds
|
||||
procd_notification() {
|
||||
local line
|
||||
|
||||
while read -r -t "${2}" line <&3; do
|
||||
case "${line}" in
|
||||
*"${1}"*) return 0 ;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
if /etc/init.d/dockerd running; then
|
||||
service_stop "/usr/bin/dockerd"
|
||||
fi
|
||||
local i=0
|
||||
|
||||
procd_running dockerd || return 0
|
||||
|
||||
# Subscribe to procd's notifications before it stops dockerd, to learn when it is done.
|
||||
# The subscriber leaves procd's lock (fd 1000) to this script, which releases it on exit.
|
||||
STOP_EVENTS="/var/run/dockerd.stop.$$"
|
||||
mkfifo "${STOP_EVENTS}" || return 0
|
||||
ubus -t 330 subscribe service > "${STOP_EVENTS}" 1000>&- &
|
||||
STOP_SUBSCRIBER=$!
|
||||
exec 3< "${STOP_EVENTS}"
|
||||
|
||||
# The subscription takes effect a moment later, and a stop notified before it would be missed:
|
||||
# wait until procd passes on an event sent to itself
|
||||
while [ "${i}" -lt 10 ]; do
|
||||
ubus call service event '{ "type": "dockerd.stopping", "data": {} }'
|
||||
if procd_notification '"type":"dockerd.stopping"' 1; then
|
||||
STOP_SUBSCRIBED=1
|
||||
return 0
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
service_stopped() {
|
||||
[ -n "${STOP_EVENTS}" ] || return 0
|
||||
|
||||
# Wait for dockerd, which exits after stopping the containers, so that a shutdown unmounts the data root after them
|
||||
[ -n "${STOP_SUBSCRIBED}" ] && procd_notification '"service.stop": {"service":"dockerd"}' 330
|
||||
exec 3<&-
|
||||
# A restart ignores SIGTERM while it stops dockerd, and so does the subscriber it started
|
||||
kill -KILL "${STOP_SUBSCRIBER}" 2> /dev/null
|
||||
rm -f "${STOP_EVENTS}"
|
||||
}
|
||||
Reference in new issue
Block a user