Ho about this then

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-01-07 09:12:12 +03:00
parent 3c6fb9796b
commit 51d452934a
1 changed files with 13 additions and 8 deletions

21
ssm
View File

@ -26,12 +26,16 @@ svc() {
declare job_pid
svc::cleanup() {
"${service_command_stop[@]}"
kill -n "$service_stop_signal" "$job_pid"
pid_wait "$job_pid"
rm -f "$svc_pidfile" "$service_ready_flag"
}; trap 'svc::cleanup' TERM
svc::reload() {
kill -n "$service_reload_signal" "$job_pid"
}; trap 'svc::reload' HUP
"$@" & job_pid=$!
printf '%s' "$job_pid" > "$svc_pidfile"
@ -214,8 +218,8 @@ read_systemd_service() {
case $key in
(pidfile) service_pidfile=$value;;
(execstart) eval "service_command=( $value )";;
(execstop) eval "service_command_stop=( $value )";;
(execreload) eval "service_command_reload=( $value )";;
(execstop) eval "stop() { $value; }";;
(execreload) eval "reload() { $value; }";;
(restart) [[ $value == 'always' ]] && service_respawn=1;;
esac
;;
@ -264,7 +268,12 @@ start() {
## Usually just sends HUP
reload() {
(( service_running )) || return 3
"${service_command_reload[@]}"
if (( service_managed )); then
kill -n 1 "$service_pid"
else
"${service_command_reload[@]}"
fi
}
## Stop the service
@ -502,10 +511,6 @@ main() {
fi
fi
# The stop and reload commands need the service pid
default service_command_stop kill -n "$service_stop_signal" "$service_pid"
default service_command_reload kill -n "$service_reload_signal" "$service_pid"
# Maybe the service is enabled?
if [[ -f "$service_enabled_flag" ]]; then
# Yay, it is!