info() and fixes

* Info function
* Fix: removing the pidfile

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2017-03-11 17:36:07 +03:00
parent 9fc3d74501
commit 7fe65f774b
1 changed files with 17 additions and 2 deletions

19
ssm
View File

@ -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