INNER CODE UNIT · Python
ensure_cloudflared_running
ChrispyBacon-dev/DockFlare · dockflare-agent/app/main.py:274
def ensure_cloudflared_running(client):
global tunnel_container, current_tunnel_version
if decommission_tombstone or desired_tunnel_state != "running" or not current_tunnel_token or not current_tunnel_name:
return
try:
existing = client.containers.get('dockflare-agent-tunnel')
existing.reload()
if existing.status == 'running':
tunnel_container = existing
if not current_tunnel_version:
current_tunnel_version = fetch_cloudflared_version(existing)
return
logging.warning(f"Detected cloudflared container in status '{existing.status}'. Redeploying.")
except docker.errors.NotFound:
logging.warning("cloudflared container missing. Redeploying.")
except Exception as e:
logging.error(f"Error inspecting cloudflared container: {e}")