mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-10-31 23:11:14 +00:00
Remove useless function
This commit is contained in:
parent
b5fa3be506
commit
0b31633309
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user