From 32709dc64cb62f440d49fa69238ec96784f212f9 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 16 Jan 2024 21:53:06 +0700 Subject: [PATCH] internal/router: use daemon -r option So if ctrld is killed unexpectedly, daemon will respawn new ctrld and keep the system DNS working. --- internal/router/os_freebsd.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/internal/router/os_freebsd.go b/internal/router/os_freebsd.go index 3b7c0a3..c38eebc 100644 --- a/internal/router/os_freebsd.go +++ b/internal/router/os_freebsd.go @@ -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" `