Skip to content

Commit d5bace0

Browse files
cloudflared tunnel version delay for reporting
1 parent bc2b904 commit d5bace0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

DockFlare-Agent/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def _run_cloudflared_container(client, tunnel_name, tunnel_token):
206206
restart_policy={"Name": "unless-stopped"},
207207
environment={"TUNNEL_TOKEN": tunnel_token}
208208
)
209+
time.sleep(2)
209210
current_tunnel_version = fetch_cloudflared_version(tunnel_container)
210211
logging.info(f"cloudflared container started: {tunnel_container.short_id}")
211212
report_event_to_master("tunnel_status", {
@@ -400,6 +401,23 @@ def manage_tunnels(client):
400401
save_tunnel_state()
401402
ensure_cloudflared_running(client)
402403

404+
elif action == "restart_tunnel":
405+
tunnel_token = cmd.get("tunnel_token")
406+
tunnel_name = cmd.get("tunnel_name")
407+
tunnel_id = cmd.get("tunnel_id")
408+
if tunnel_token and tunnel_name and tunnel_id:
409+
logging.info(f"Received command to restart tunnel '{tunnel_name}'.")
410+
_remove_existing_container(client)
411+
logging.info("Restarting cloudflared tunnel container...")
412+
_run_cloudflared_container(client, tunnel_name, tunnel_token)
413+
current_tunnel_token = tunnel_token
414+
current_tunnel_id = tunnel_id
415+
current_tunnel_name = tunnel_name
416+
desired_tunnel_state = "running"
417+
save_tunnel_state()
418+
else:
419+
logging.warning("Received restart_tunnel command with missing parameters.")
420+
403421
elif action == "stop_tunnel":
404422
logging.info("Received command to stop cloudflared tunnel container.")
405423
desired_tunnel_state = "stopped"

0 commit comments

Comments
 (0)