Skip to content

Commit cc7c161

Browse files
authored
Merge pull request #24 from threefoldtech/development-fix-server-not-sutting-down-on-error
stop server if couldn't start properly
2 parents d345767 + 2c5e8c8 commit cc7c161

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

node-registrar/cmds/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func Run() error {
9696
quit := make(chan os.Signal, 1)
9797
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)
9898

99-
log.Info().Msg("server is running on port :8080")
99+
log.Info().Msgf("server is running on port :%d", f.serverPort)
100100

101101
err = s.Run(quit, fmt.Sprintf("%s:%d", f.domain, f.serverPort))
102102
if err != nil {

node-registrar/pkg/server/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66
"os"
77
"sync"
8+
"syscall"
89

910
"github.com/gin-gonic/gin"
1011
"github.com/rs/zerolog/log"
@@ -48,6 +49,9 @@ func (s Server) Run(quit chan os.Signal, addr string) error {
4849
}()
4950

5051
err := server.ListenAndServe()
52+
if err != nil {
53+
quit <- syscall.SIGINT
54+
}
5155
wg.Wait()
5256

5357
return err

0 commit comments

Comments
 (0)