Ho about this then
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
3c6fb9796b
commit
51d452934a
21
ssm
21
ssm
|
@ -26,12 +26,16 @@ svc() {
|
||||||
declare job_pid
|
declare job_pid
|
||||||
|
|
||||||
svc::cleanup() {
|
svc::cleanup() {
|
||||||
"${service_command_stop[@]}"
|
kill -n "$service_stop_signal" "$job_pid"
|
||||||
|
|
||||||
pid_wait "$job_pid"
|
pid_wait "$job_pid"
|
||||||
rm -f "$svc_pidfile" "$service_ready_flag"
|
rm -f "$svc_pidfile" "$service_ready_flag"
|
||||||
}; trap 'svc::cleanup' TERM
|
}; trap 'svc::cleanup' TERM
|
||||||
|
|
||||||
|
svc::reload() {
|
||||||
|
kill -n "$service_reload_signal" "$job_pid"
|
||||||
|
}; trap 'svc::reload' HUP
|
||||||
|
|
||||||
"$@" & job_pid=$!
|
"$@" & job_pid=$!
|
||||||
|
|
||||||
printf '%s' "$job_pid" > "$svc_pidfile"
|
printf '%s' "$job_pid" > "$svc_pidfile"
|
||||||
|
@ -214,8 +218,8 @@ read_systemd_service() {
|
||||||
case $key in
|
case $key in
|
||||||
(pidfile) service_pidfile=$value;;
|
(pidfile) service_pidfile=$value;;
|
||||||
(execstart) eval "service_command=( $value )";;
|
(execstart) eval "service_command=( $value )";;
|
||||||
(execstop) eval "service_command_stop=( $value )";;
|
(execstop) eval "stop() { $value; }";;
|
||||||
(execreload) eval "service_command_reload=( $value )";;
|
(execreload) eval "reload() { $value; }";;
|
||||||
(restart) [[ $value == 'always' ]] && service_respawn=1;;
|
(restart) [[ $value == 'always' ]] && service_respawn=1;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
@ -264,7 +268,12 @@ start() {
|
||||||
## Usually just sends HUP
|
## Usually just sends HUP
|
||||||
reload() {
|
reload() {
|
||||||
(( service_running )) || return 3
|
(( service_running )) || return 3
|
||||||
"${service_command_reload[@]}"
|
|
||||||
|
if (( service_managed )); then
|
||||||
|
kill -n 1 "$service_pid"
|
||||||
|
else
|
||||||
|
"${service_command_reload[@]}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Stop the service
|
## Stop the service
|
||||||
|
@ -502,10 +511,6 @@ main() {
|
||||||
fi
|
fi
|
||||||
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?
|
# Maybe the service is enabled?
|
||||||
if [[ -f "$service_enabled_flag" ]]; then
|
if [[ -f "$service_enabled_flag" ]]; then
|
||||||
# Yay, it is!
|
# Yay, it is!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user