kiast-drone-collector/cmd/collector/main.go

36 lines
667 B
Go
Raw Permalink Normal View History

2019-08-06 00:54:55 +00:00
package main
import (
"log"
"net"
"os"
"os/signal"
"syscall"
"git.loafle.net/outsourcing/kiast-drone-collector/pkg/drone"
)
func main() {
laddr, err := net.ResolveTCPAddr("tcp", ":48879")
if nil != err {
log.Fatalln(err)
}
listener, err := net.ListenTCP("tcp", laddr)
if nil != err {
log.Fatalln(err)
}
log.Println("listening on", listener.Addr())
// Make a new service and send it into the background.
service := drone.NewService()
go service.Serve(listener)
// Handle SIGINT and SIGTERM.
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
log.Println(<-ch)
// Stop the service gracefully.
service.Stop()
}