pidfiles are evil

This commit is contained in:
2014-07-03 11:05:52 +04:00
parent c9168818d4
commit 4bf86dc02f
12 changed files with 38 additions and 28 deletions

View File

@@ -2,7 +2,8 @@
unset reload
service_command='/usr/bin/cjdroute'
service_command='/usr/local/sbin/cjdroute-start'
service_respawn=true
cjdroute_config='/etc/cjdroute.conf'
cjdroute_admin_port='11234'
@@ -16,10 +17,6 @@ cjdroute.check_tun_module() {
}
}
get_pid() {
lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2
}
start() {
cjdroute.check_tun_module || { return 1; }
@@ -28,7 +25,16 @@ start() {
return 1
}
"$service_command" < "${cjdroute_config}" &>"$service_logfile" && {
watchman.msg "${service_name} started"
watchman.start
}
stop() {
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
# Stopping the actual s-o-b daemon that won't die properly.
cjdroute_control_pid=`lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2`
watchman.pid_check "$cjdroute_control_pid" && {
kill "$cjdroute_control_pid"
watchman.pid_wait "$cjdroute_control_pid"
}
}