INNER CODE UNIT · Python
_run_cloudflared_container
ChrispyBacon-dev/DockFlare · dockflare-agent/app/main.py:312
def _run_cloudflared_container(client, tunnel_name, tunnel_token):
global tunnel_container, current_tunnel_version
if not tunnel_token:
logging.error("Cannot start cloudflared: missing tunnel token.")
return False
try:
tunnel_container = client.containers.run(
CLOUDFLARED_IMAGE,
command=["tunnel", "--no-autoupdate", "run"],
detach=True,
name="dockflare-agent-tunnel",
network=CLOUDFLARED_NETWORK_NAME,
restart_policy={"Name": "unless-stopped"},
environment={"TUNNEL_TOKEN": tunnel_token}
)
time.sleep(2)
current_tunnel_version = fetch_cloudflared_version(tunnel_container)
logging.info(f"cloudflared container started: {tunnel_container.short_id}")