Fix exit signal handling

This commit is contained in:
Zoltán Papp 2024-08-21 15:54:36 +02:00
parent 3bd820f2e4
commit 7633cca3b1
2 changed files with 6 additions and 5 deletions

View File

@ -166,11 +166,13 @@ func execute(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to create relay server: %v", err)
}
log.Infof("server will be available on: %s", srv.InstanceURL())
err = srv.Listen(srvListenerCfg)
if err != nil {
return fmt.Errorf("failed to bind server: %s", err)
go func() {
if err := srv.Listen(srvListenerCfg); err != nil {
log.Errorf("failed to bind server: %s", err)
}
}()
// it will block until exit signal
waitForExitSignal()
err = srv.Close()

View File

@ -38,7 +38,6 @@ func (l *Listener) Listen(acceptFn func(conn net.Conn)) error {
var err error
if l.TLSConfig != nil {
err = l.server.ListenAndServeTLS("", "")
} else {
err = l.server.ListenAndServe()
}