diff --git a/ssm b/ssm index 5a44750..a4b74bd 100755 --- a/ssm +++ b/ssm @@ -26,11 +26,10 @@ svc() { declare job_pid svc::cleanup() { - kill -n "$service_stop_signal" "$job_pid" + "${service_command_stop[@]}" - pid_wait "$job_pid" && { - rm -f "$svc_pidfile" "$service_ready_flag" - } + pid_wait "$job_pid" + rm -f "$svc_pidfile" "$service_ready_flag" }; trap 'svc::cleanup' TERM "$@" & job_pid=$! @@ -281,7 +280,11 @@ stop() { else (( service_running )) || return 3 - "${service_command_stop[@]}" || return 1 + if (( service_managed )); then + nullexec kill "$service_pid" || return 1 + else + "${service_command_stop[@]}" || return 1 + fi pid_wait "$service_pid" || return 5 > "$service_stopped_flag" @@ -425,16 +428,18 @@ main() { } done - # Search for a systemd service too - for i in {/etc/systemd,/run/systemd,/lib/systemd,/usr/lib/systemd}/system/$1.service; do - [[ -f "$i" ]] && { - service_name=$1 - service_systemd=1 - service_config=$i - read_systemd_service "$i" - break - } - done + [[ $service_config ]] || { + # Search for a systemd service too + for i in {/etc/systemd,/run/systemd,/lib/systemd,/usr/lib/systemd}/system/$1.service; do + [[ -f "$i" ]] && { + service_name=$1 + service_systemd=1 + service_config=$i + read_systemd_service "$i" + break + } + done + } fi # Die if there is no service config file