Only main catches signals

This commit is contained in:
Bel LaPointe
2018-06-21 13:51:57 -06:00
parent b5de257f60
commit e28cbfe5ce

14
main.go
View File

@@ -10,7 +10,10 @@ import (
"local/natsc" "local/natsc"
"local/system/sysconf" "local/system/sysconf"
"net/http" "net/http"
"os"
"os/signal"
"regexp" "regexp"
"syscall"
"time" "time"
) )
@@ -25,7 +28,7 @@ func main() {
client := &http.Client{Timeout: time.Second * 30} client := &http.Client{Timeout: time.Second * 30}
sub, err := natsc.NewSubscriber(config.DB) sub, err := natsc.NewSubscriber(config.DB)
if err != nil { if err != nil {
exit <- true <-exit
panic(err) panic(err)
} }
defer sub.Close() 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" //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 <-exit
select {
case <-exit:
case <-time.After(time.Second * 10):
}
logger.Log("Exit received") logger.Log("Exit received")
} }