Skip to content

Commit 8eb921b

Browse files
committed
Fix bug in cloudflared tunnel info, for totally fresh named tunnels
1 parent efd6626 commit 8eb921b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ WORKDIR /app/
1212

1313
ENV NO_AUTOUPDATE="true"
1414
ENV TUNNEL_TRANSPORT_LOGLEVEL="error"
15-
ENV TUNNEL_LOGLEVEL="error"
15+
ENV TUNNEL_LOGLEVEL="info"
1616
ENV TUNNEL_METRICS="localhost:2000"
1717

1818
HEALTHCHECK --interval=5s --retries=6 --timeout=3s CMD wget -q ${TUNNEL_METRICS}/ready -O -

Dockerfile.entrypoint

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ if [ ! -f /etc/cloudflared/config.yml ]; then
5252
echo "---" >/etc/cloudflared/config.yml
5353
fi
5454

55-
export TUNNEL_FORCE_PROVISIONING_DNS='false'
5655
derived_tunnel_name=$(echo "${TUNNEL_HOSTNAME}" | sed "s,^.*://,,g" | tr '[:upper:]' '[:lower:]')
5756
export TUNNEL_NAME="${TUNNEL_NAME:-${derived_tunnel_name}}"
5857

5958
# Check for active connections and/or cleanup pending connections
60-
tunnel_info=$(cloudflared --loglevel error tunnel info --output json "${TUNNEL_NAME}")
59+
set +e
60+
tunnel_info=$(cloudflared --loglevel error tunnel info --output json "${TUNNEL_NAME}" 2> /dev/null)
61+
set -e
6162
is_active=$(echo "${tunnel_info}" | jq '.conns[] | .conns[] | select(.is_pending_reconnect == false) | length' | wc -l)
6263
if [ "$is_active" != "0" ]; then
6364
printAndExit 1 "Active tunnels for '${TUNNEL_NAME}' found, shutting down"
@@ -84,4 +85,4 @@ cloudflared --loglevel 'error' tunnel route dns --overwrite-dns "${TUNNEL_NAME}"
8485

8586
unset TUNNEL_HOSTNAME
8687

87-
exec "cloudflared" "tunnel"
88+
exec "cloudflared" "tunnel" "run" "${derived_tunnel_name}"

0 commit comments

Comments
 (0)