Use CLI context when running tunnel

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.
This commit is contained in:
Kyle Carberry 2022-03-09 15:15:52 -06:00
parent 5352b3cf04
commit 7f1fc77731
1 changed files with 1 additions and 1 deletions

View File

@ -274,7 +274,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)