gohttp/main.go

32 lines
503 B
Go

package main
import (
"os"
"os/signal"
"syscall"
"git.pyer.club/kingecg/godaemon"
)
func main() {
LoadConfig("")
daemon := godaemon.NewGoDaemon(start, stop)
daemon.Start()
}
func start(g *godaemon.GoDaemon) {
var 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
}
func stop(g *godaemon.GoDaemon) {
g.Running.Process.Signal(syscall.SIGTERM)
}