Commit f39a194f authored by nanahira's avatar nanahira

add healthy check

parent a9b17e15
Pipeline #16407 passed with stages
in 2 minutes and 35 seconds
......@@ -11,16 +11,42 @@ while [[ "$daemonReady" != "0" ]]; do
done
echo "Daemon started"
if [[ ! -f "/var/lib/cloudflare-warp/reg.json" ]]; then
initProxy() {
if [[ ! -f "/var/lib/cloudflare-warp/reg.json" ]]; then
if [[ -n "$WARP_LICENSE" ]]; then
warp-cli --accept-tos set-license "$WARP_LICENSE"
else
warp-cli --accept-tos register
fi
fi
fi
warp-cli set-mode proxy
warp-cli set-proxy-port $LOCAL_PROXY_PORT
warp-cli connect
}
watcher() {
workedOnce=0
while true; do
echo "Checking proxy status"
curl -x localhost:$LOCAL_PROXY_PORT -o /dev/null -s https://www.google.com/
checkResult=$?
if [[ $checkResult -gt 0 ]]; then
if [[ $workedOnce -eq 0 ]]; then
echo "Proxy is still starting up"
else
echo "Proxy is down, restarting"
initProxy
fi
sleep 10
else
echo "Proxy is up"
workedOnce=1
sleep 5
fi
done
}
warp-cli set-mode proxy
warp-cli set-proxy-port $LOCAL_PROXY_PORT
warp-cli connect
initProxy
watcher &
"$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment