package main import ( "os" "os/signal" "syscall" "git.pyer.club/kingecg/godaemon" ) func main() { LoadConfig("") daemon := godaemon.NewGoDaemon(start, stop) daemon.Start() } var waiter chan os.Signal func start(g *godaemon.GoDaemon) { waiter = make(chan os.Signal, 1) // buffered channel signal.Notify(waiter, syscall.SIGTERM, syscall.SIGINT) httpd := &GoHttp{} httpd.Start() // blocks here until there's a signal <-waiter httpd.logger.Info("Exit") } func stop(g *godaemon.GoDaemon) { g.Running.Process.Signal(syscall.SIGTERM) }