Skip to content

Commit

Permalink
Use CLI context when running tunnel (#597)
Browse files Browse the repository at this point in the history
When embedding the tunnel command inside another CLI, it
became difficult to test shutdown behavior due to this leaking
tunnel. By using the command context, we're able to shutdown
gracefully.
  • Loading branch information
kylecarbs authored Dec 14, 2023
1 parent 9e1f4c2 commit 61a1653
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/cloudflared/tunnel/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func StartServer(
logClientOptions(c, log)

// this context drives the server, when it's cancelled tunnel and all other components (origins, dns, etc...) should stop
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(c.Context)
defer cancel()

go waitForSignal(graceShutdownC, log)
Expand Down

0 comments on commit 61a1653

Please sign in to comment.