Merge pull request #1099 from tcely/patch-16

Resolve bundles in restart_services.sh
This commit is contained in:
meeb 2025-06-11 20:45:30 +10:00 committed by GitHub
commit 06b175f762
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,26 +1,51 @@
#!/usr/bin/env sh #!/usr/bin/env sh
dir='/run/service' _dir='/run/service'
svc_path() ( svc_path() (
cd "${dir}" cd "${_dir}" &&
realpath -e -s "$@" realpath -e -s "$@"
) )
_bundles="$(
find '/etc/s6-overlay/s6-rc.d' -mindepth 2 -maxdepth 2 \
-name 'type' \
-execdir grep -F -q -e bundle '{}' ';' \
-printf '%P\n' | \
sed -e 's,/type$,,' ;
)"
is_a_bundle() {
local bundle
for bundle in ${_bundles}
do
if [ "$1" = "${bundle}" ]
then
return 0
fi
done
return 1
}
if [ 0 -eq $# ] if [ 0 -eq $# ]
then then
set -- \ set -- $(/command/s6-rc list user | grep -v -e '-init$')
$( cd "${dir}" && svc_path tubesync*-worker ) \
"$( svc_path gunicorn )" \
"$( svc_path nginx )"
fi fi
for service in $( svc_path "$@" ) for arg in "$@"
do do
printf -- 'Restarting %-28s' "${service#${dir}/}..." _svcs="${arg}"
_began="$( date '+%s' )" if is_a_bundle "${arg}"
/command/s6-svc -wr -r "${service}" then
_ended="$( date '+%s' )" _svcs="$(/command/s6-rc list "${arg}" | grep -v -e '-init$')"
printf -- '\tcompleted (in %2.1d seconds).\n' \ fi
"$( expr "${_ended}" - "${_began}" )" for service in $(svc_path ${_svcs})
do
printf -- 'Restarting %-28s' "${service#${_dir}/}..."
_began="$( date '+%s' )"
/command/s6-svc -wr -r "${service}"
_ended="$( date '+%s' )"
printf -- '\tcompleted (in %2.1d seconds).\n' \
"$( expr "${_ended}" - "${_began}" )"
done
done done
unset -v _began _ended service unset -v _began _ended _svcs arg service
unset -v _bundles _dir