Skip to content

Commit 10c0790

Browse files
committed
Correctly sequence the shutdown sequence
I got the order of things getting shut down wrong: Instead of shutting down the SSH server, the sequence still shut down the _tailscale_ server, which had the exact same effect as before #107. Instead, wait for the termination message, then shut down the SSH server, which causes the tailscale client to shut down.
1 parent 7b3b309 commit 10c0790

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ssh.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,15 @@ func (s *TailnetSSH) Run(ctx context.Context) error {
106106
return nil
107107
}
108108

109-
go func() {
110-
<-ctx.Done()
111-
srv.Close()
112-
}()
113-
114109
err = s.setupPrometheus(ctx, srv)
115110
if err != nil {
116111
log.Printf("Setting up prometheus failed, but continuing anyway: %v", err)
117112
}
118113
log.Printf("starting ssh server on port :22...")
114+
go func() {
115+
<-ctx.Done()
116+
_ = s.Server.Close()
117+
}()
119118
err = s.Server.Serve(listener)
120119
if err != nil && ctx.Err() == nil {
121120
return fmt.Errorf("ssh server failed serving: %w", err)

0 commit comments

Comments
 (0)