logfile cleanup
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
a5f93916cd
commit
e733ed4f6a
31
ssm
31
ssm
|
@ -89,7 +89,7 @@ svc() {
|
||||||
var job_pid
|
var job_pid
|
||||||
|
|
||||||
svc::cleanup() {
|
svc::cleanup() {
|
||||||
kill -n "$service_stop_signal" "$job_pid"
|
nullexec 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"
|
||||||
|
@ -99,7 +99,7 @@ svc() {
|
||||||
kill -n "$service_reload_signal" "$job_pid"
|
kill -n "$service_reload_signal" "$job_pid"
|
||||||
}; trap 'svc::reload' HUP
|
}; trap 'svc::reload' HUP
|
||||||
|
|
||||||
"$@" & job_pid = "$!"
|
"$@" 1>"$service_logfile_out" 2>"$service_logfile_err" & job_pid = "$!"
|
||||||
|
|
||||||
printf '%s' "$job_pid" > "$svc_pidfile"
|
printf '%s' "$job_pid" > "$svc_pidfile"
|
||||||
wait "$job_pid"
|
wait "$job_pid"
|
||||||
|
@ -297,9 +297,9 @@ start() {
|
||||||
|
|
||||||
if service_managed; then
|
if service_managed; then
|
||||||
if service_respawn; then
|
if service_respawn; then
|
||||||
svc respawn "${service_command[@]}" &>"$service_logfile" &
|
svc respawn "${service_command[@]}" &
|
||||||
else
|
else
|
||||||
svc "${service_command[@]}" &>"$service_logfile" &
|
svc "${service_command[@]}" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if timer "$service_ready_timeout" ready; then
|
if timer "$service_ready_timeout" ready; then
|
||||||
|
@ -308,11 +308,11 @@ start() {
|
||||||
return 5
|
return 5
|
||||||
fi
|
fi
|
||||||
elif service_oneshot; then
|
elif service_oneshot; then
|
||||||
"${service_command[@]}" &>"$service_logfile"; res=$?
|
"${service_command[@]}" 1>"$service_logfile_out" 2>"$service_logfile_err"; res=$?
|
||||||
(( res )) && return "$res"
|
(( res )) && return "$res"
|
||||||
printf '1' > "$service_enabled_flag"
|
printf '1' > "$service_enabled_flag"
|
||||||
else
|
else
|
||||||
exec "${service_command[@]}" &
|
exec "${service_command[@]}" 1>"$service_logfile_out" 2>"$service_logfile_err" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -368,7 +368,9 @@ info() {
|
||||||
"$_status_label" "$_status" \
|
"$_status_label" "$_status" \
|
||||||
"Exec" "${service_command[*]} ${service_args[*]}" \
|
"Exec" "${service_command[*]} ${service_args[*]}" \
|
||||||
"Respawn" "${service_respawn:-false}" \
|
"Respawn" "${service_respawn:-false}" \
|
||||||
"Config path" "${service_config}" \
|
"Config path" "$service_config" \
|
||||||
|
"Output log" "$service_logfile_out" \
|
||||||
|
"Error log" "$service_logfile_err"
|
||||||
|
|
||||||
if _status == 'yes'; then
|
if _status == 'yes'; then
|
||||||
_info_items += \
|
_info_items += \
|
||||||
|
@ -386,7 +388,7 @@ restart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
edit() { $EDITOR "$service_config"; }
|
edit() { $EDITOR "$service_config"; }
|
||||||
logs() { $PAGER "$service_logfile"; }
|
logs() { printf '%s\n' "$service_logfile_out" "$service_logfile_err"; }
|
||||||
|
|
||||||
## Status is a bit of a special case. It's talkative.
|
## Status is a bit of a special case. It's talkative.
|
||||||
status() {
|
status() {
|
||||||
|
@ -414,7 +416,8 @@ var service_pid \
|
||||||
service_path \
|
service_path \
|
||||||
service_name \
|
service_name \
|
||||||
service_args \
|
service_args \
|
||||||
service_logfile \
|
service_logfile_out \
|
||||||
|
service_logfile_err \
|
||||||
service_ready_flag \
|
service_ready_flag \
|
||||||
service_enabled_flag \
|
service_enabled_flag \
|
||||||
service_stopped_flag \
|
service_stopped_flag \
|
||||||
|
@ -446,6 +449,7 @@ var service_ready_timeout = 15
|
||||||
var service_stop_signal = 15
|
var service_stop_signal = 15
|
||||||
var service_reload_signal = 1
|
var service_reload_signal = 1
|
||||||
var service_signals = 1 10 12
|
var service_signals = 1 10 12
|
||||||
|
var service_nologs = 0
|
||||||
var systemd = 0
|
var systemd = 0
|
||||||
var systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/system
|
var systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/system
|
||||||
var ssm_config = 0
|
var ssm_config = 0
|
||||||
|
@ -568,11 +572,18 @@ svc_pidfile = "$rundir/$service_name.pid"
|
||||||
|
|
||||||
# Service-level defaults
|
# Service-level defaults
|
||||||
service_pidfile := "$svc_pidfile"
|
service_pidfile := "$svc_pidfile"
|
||||||
service_logfile := "$logdir/$service_name.log"
|
service_logfile_out := "$logdir/${service_name}.out.log"
|
||||||
|
service_logfile_err := "$logdir/${service_name}.err.log"
|
||||||
service_ready_flag := "$rundir/$service_name.ready"
|
service_ready_flag := "$rundir/$service_name.ready"
|
||||||
service_enabled_flag := "$rundir/$service_name.enabled"
|
service_enabled_flag := "$rundir/$service_name.enabled"
|
||||||
service_stopped_flag := "$rundir/$service_name.stopped"
|
service_stopped_flag := "$rundir/$service_name.stopped"
|
||||||
|
|
||||||
|
# A shortcut for disabling logging
|
||||||
|
if service_nologs; then
|
||||||
|
service_logfile_out = '/dev/null'
|
||||||
|
service_logfile_err = '/dev/null'
|
||||||
|
fi
|
||||||
|
|
||||||
# Let's see if there's a PID
|
# Let's see if there's a PID
|
||||||
if [[ -f "$service_pidfile" ]]; then
|
if [[ -f "$service_pidfile" ]]; then
|
||||||
service_pid = "$(<$service_pidfile)"
|
service_pid = "$(<$service_pidfile)"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user