experimental netns support and some fixes

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2020-03-28 19:12:15 +03:00
parent bba7eef3d9
commit c5bbf92022

12
ssm
View File

@ -143,10 +143,12 @@ run_service_action() {
spawn() { spawn() {
if [[ $service_logfile_out == "$service_logfile_err" ]]; then if [[ $service_logfile_out == "$service_logfile_err" ]]; then
exec "$@" >"$service_logfile_out" 2>&1 exec 3>"$service_logfile_out"
else else
exec "$@" >"$service_logfile_out" 2>"$service_logfile_err" exec 3>"$service_logfile_err"
fi fi
exec "$@" >"$service_logfile_out" 2>&3
}; readonly spawn; }; readonly spawn;
cgroup_get_procs() { cgroup_get_procs() {
@ -243,7 +245,7 @@ svc() {
# One service failure, two service failures... # One service failure, two service failures...
if service_success_exit u "$job_exit"; then if service_success_exit u "$job_exit"; then
job_success = 1 job_success = 1
(( fail_counter )) && fail_counter-- (( fail_counter )) && fail_counter=0
else else
job_success = 0 job_success = 0
fail_counter++ fail_counter++
@ -416,6 +418,10 @@ start() {
mktmpfiles || return 13 mktmpfiles || return 13
if [[ $service_netns ]]; then
service_command=( ip netns exec "$service_netns" "${service_command[@]}" )
fi
svc "${service_command[@]}" & job=$! svc "${service_command[@]}" & job=$!
if service_oneshot; then if service_oneshot; then