cjdroute
This commit is contained in:
parent
2093fe139b
commit
0d6559d31d
|
@ -1,9 +1,9 @@
|
||||||
#!/usr/bin/env watchman
|
#!/usr/bin/env watchman
|
||||||
# Two warnings:
|
# Two warnings:
|
||||||
# 1) This script uses a script to run cjdroute and feed it
|
# 1) This script uses a script to run cjdroute and feed it
|
||||||
# the config. It can be found in the main cjdns repo:
|
# the config. It can be found in the main cjdns repo:
|
||||||
# contrib/sh/run-cjdroute.sh
|
# contrib/sh/run-cjdroute.sh
|
||||||
# Or here: http://ix.io/fYT
|
# Or here: http://ix.io/fYT
|
||||||
# 2) service_respawn is disabled by default because you need
|
# 2) service_respawn is disabled by default because you need
|
||||||
# "noBackground":1 in cjdroute.conf for it to actually work.
|
# "noBackground":1 in cjdroute.conf for it to actually work.
|
||||||
# Barely.
|
# Barely.
|
||||||
|
@ -28,11 +28,33 @@ start() {
|
||||||
watchman.start
|
watchman.start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_control_pid() {
|
||||||
|
lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
# Check the actual cjdroute process and not the watchdog
|
||||||
|
cjdroute_control_pid=$( get_control_pid )
|
||||||
|
|
||||||
|
counter=0
|
||||||
|
until kill -0 "$cjdroute_control_pid"; do
|
||||||
|
cjdroute_control_pid=$( get_control_pid )
|
||||||
|
(( counter >= 5 )) && {
|
||||||
|
watchman.msg "cjdroute is down"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
(( counter++ ))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
watchman.msg "cjdroute is running ($cjdroute_control_pid)"
|
||||||
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
|
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
|
||||||
|
|
||||||
# Stopping the actual s-o-b daemon that won't die properly.
|
# 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)
|
cjdroute_control_pid=$( get_control_pid )
|
||||||
watchman.pid_check "$cjdroute_control_pid" && {
|
watchman.pid_check "$cjdroute_control_pid" && {
|
||||||
kill "$cjdroute_control_pid"
|
kill "$cjdroute_control_pid"
|
||||||
watchman.pid_wait "$cjdroute_control_pid"
|
watchman.pid_wait "$cjdroute_control_pid"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user