diff --git a/cmd/dmsgweb/commands/dmsgweb.go b/cmd/dmsgweb/commands/dmsgweb.go index bdad1a58..edc2fa6a 100644 --- a/cmd/dmsgweb/commands/dmsgweb.go +++ b/cmd/dmsgweb/commands/dmsgweb.go @@ -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 @@ -262,10 +269,6 @@ var RootCmd = &cobra.Command{ wg.Done() }() wg.Wait() - os.Exit(0) //this should not be necessary - // <-ctx.Done() - cancel() - closeDmsg() }, }