internal/router: use daemon -r option

So if ctrld is killed unexpectedly, daemon will respawn new ctrld and
keep the system DNS working.
This commit is contained in:
Cuong Manh Le
2024-01-16 21:53:06 +07:00
committed by Cuong Manh Le
parent 71f26a6d81
commit 32709dc64c

View File

@@ -137,20 +137,9 @@ rcvar="${name}_enable"
pidfile="/var/run/${name}.pid"
child_pidfile="/var/run/${name}_child.pid"
command="/usr/sbin/daemon"
daemon_args="-P ${pidfile} -p ${child_pidfile} -t \"${name}: daemon\"{{if .WorkingDirectory}} -c {{.WorkingDirectory}}{{end}}"
daemon_args="-r -P ${pidfile} -p ${child_pidfile} -t \"${name}: daemon\"{{if .WorkingDirectory}} -c {{.WorkingDirectory}}{{end}}"
command_args="${daemon_args} {{.Path}}{{range .Arguments}} {{.}}{{end}}"
stop_cmd="ctrld_stop"
ctrld_stop() {
pid=$(cat ${pidfile})
child_pid=$(cat ${child_pidfile})
if [ -e "${child_pidfile}" ]; then
kill -s TERM "${child_pid}"
wait_for_pids "${child_pid}" "${pidfile}"
fi
}
load_rc_config "${name}"
run_rc_command "$1"
`