Remove useless function

This commit is contained in:
Daniel Carrillo 2023-03-21 20:19:11 +01:00
parent b5fa3be506
commit 0b31633309
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16

View File

@ -46,56 +46,51 @@ func Setup(ctx context.Context, handler http.Handler) *Factory {
} }
} }
func (w *Factory) Run() { func (f *Factory) Run() {
w.start() f.start()
log.Printf("Starting server handler...")
w.Watcher()
}
func (w *Factory) Watcher() {
signalChan := make(chan os.Signal, 3) signalChan := make(chan os.Signal, 3)
signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM) signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
var s os.Signal var s os.Signal
for { for {
s = <-signalChan s = <-signalChan
if s == syscall.SIGHUP { if s == syscall.SIGHUP {
w.stop() f.stop()
models.CloseDBs() models.CloseDBs()
models.Setup(setting.App.GeodbPath.City, setting.App.GeodbPath.ASN) models.Setup(setting.App.GeodbPath.City, setting.App.GeodbPath.ASN)
w.start() f.start()
} else { } else {
log.Printf("Shutting down...") log.Printf("Shutting down...")
w.stop() f.stop()
models.CloseDBs() models.CloseDBs()
break break
} }
} }
} }
func (w *Factory) start() { func (f *Factory) start() {
if w.tcpServer != nil { if f.tcpServer != nil {
w.tcpServer.Start() f.tcpServer.Start()
} }
if w.tlsServer != nil { if f.tlsServer != nil {
w.tlsServer.Start() f.tlsServer.Start()
if w.quicServer != nil { if f.quicServer != nil {
w.quicServer.Start() f.quicServer.Start()
} }
} }
} }
func (w *Factory) stop() { func (f *Factory) stop() {
if w.tcpServer != nil { if f.tcpServer != nil {
w.tcpServer.Stop() f.tcpServer.Stop()
} }
if w.tlsServer != nil { if f.tlsServer != nil {
if w.quicServer != nil { if f.quicServer != nil {
w.quicServer.Stop() f.quicServer.Stop()
} }
w.tlsServer.Stop() f.tlsServer.Stop()
} }
} }