Only main catches signals
parent
b5de257f60
commit
e28cbfe5ce
14
main.go
14
main.go
|
|
@ -10,7 +10,10 @@ import (
|
|||
"local/natsc"
|
||||
"local/system/sysconf"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"regexp"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -25,7 +28,7 @@ func main() {
|
|||
client := &http.Client{Timeout: time.Second * 30}
|
||||
sub, err := natsc.NewSubscriber(config.DB)
|
||||
if err != nil {
|
||||
exit <- true
|
||||
<-exit
|
||||
panic(err)
|
||||
}
|
||||
defer sub.Close()
|
||||
|
|
@ -43,7 +46,16 @@ func main() {
|
|||
}()
|
||||
//magnets <- "magnet:?xt=urn:btih:64b2b05f61d2b9ef3213fce9860fb45c844d77fb&dn=checkmyiptorrent&tr=http%3A%2F%2F34.204.227.31%2Fcheckmytorrentipaddress.php"
|
||||
|
||||
sigc := make(chan os.Signal)
|
||||
signal.Notify(sigc,
|
||||
syscall.SIGINT,
|
||||
)
|
||||
<-sigc
|
||||
<-exit
|
||||
select {
|
||||
case <-exit:
|
||||
case <-time.After(time.Second * 10):
|
||||
}
|
||||
logger.Log("Exit received")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue