Skip to content

Commit

Permalink
improve graceful shutdown process
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpalide committed Dec 10, 2023
1 parent c1346b5 commit e75e550
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/dmsgweb/commands/dmsgweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ var RootCmd = &cobra.Command{
}
defer closeDmsg()

go func() {
<-ctx.Done()
cancel()
closeDmsg()
os.Exit(0) //this should not be necessary
}()

httpC = http.Client{Transport: dmsghttp.MakeHTTPTransport(ctx, dmsgC)}

// Create a SOCKS5 server with custom name resolution
Expand Down Expand Up @@ -262,10 +269,6 @@ var RootCmd = &cobra.Command{
wg.Done()
}()
wg.Wait()
os.Exit(0) //this should not be necessary
// <-ctx.Done()
cancel()
closeDmsg()
},
}

Expand Down

0 comments on commit e75e550

Please sign in to comment.