Skip to content

Conversation

@HueCodes
Copy link

@HueCodes HueCodes commented Jan 7, 2026

This adds a --pidfile flag to the cloudflared access tcp command (also applies to the ssh/rdp/smb aliases).

When specified, the process writes its PID to the given file path on startup. This makes it much easier to manage the process in scripts and CI/CD pipelines without resorting to fragile pgrep patterns.

Usage looks like:

  cloudflared access tcp --hostname https://app.example.com --url 127.0.0.1:8080 --pidfile /var/run/cloudflared.pid &

  # later, clean shutdown
  kill $(cat /var/run/cloudflared.pid)

Tilde expansion is supported for paths like ~/.cloudflared.pid.

The implementation follows the same pattern used by the existing --pidfile flag in the tunnel command, using go-homedir for path expansion and logging errors rather than failing hard if the pidfile can't be written.

Closes #723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💡--pidfile support for "cloudflared access"

1 participant