kiast-drone-collector/cmd/collector/main.go
2019-08-09 14:06:04 +09:00

36 lines
667 B
Go

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()
}