From 7fe65f774b626b27304560c95fca6d77dc95d75c Mon Sep 17 00:00:00 2001 From: fbt Date: Sat, 11 Mar 2017 17:36:07 +0300 Subject: [PATCH] info() and fixes * Info function * Fix: removing the pidfile Signed-off-by: fbt --- ssm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ssm b/ssm index 87f0fbb..6aff634 100755 --- a/ssm +++ b/ssm @@ -27,14 +27,16 @@ svc() { kill -n "$service_stop_signal" "$job_pid" pid_wait "$job_pid" && { - rm -f $svc_pidfile $service_ready_flag + rm -f "$svc_pidfile" "$service_ready_flag" } - }; trap 'svc::cleanup' TERM + } "$@" & job_pid=$! printf '%s' "$job_pid" > "$svc_pidfile" wait "$job_pid" + + svc::cleanup } ## Respawn @@ -49,6 +51,8 @@ respawn() { wait "${jobs[@]}" fi + rm -vf "$svc_pidfile" "$service_ready_flag" &>>/tmp/ssm.log + exit 0 }; trap 'respawn::cleanup' TERM @@ -251,6 +255,17 @@ super_stop() { fi } +info() { + declare info=() + + printf "%12s: %s\n" \ + "Name" "$service_name" \ + "Exec" "$service_command ${service_args[*]}" \ + "Respawn" "${service_respawn:-false}" \ + "PIDfile" "${service_pidfile:-none}" \ + "PID" "${service_pid:-none}" +} + result() { declare rc=$1; shift declare -A msgs