Add ipv6 support and enable go mod
This commit is contained in:
27
main.go
27
main.go
@@ -3,20 +3,33 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/golang/glog"
|
||||
c "github.com/mayuresh82/gocast/config"
|
||||
"github.com/mayuresh82/gocast/controller"
|
||||
"github.com/mayuresh82/gocast/server"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var (
|
||||
config = flag.String("config", "", "Path to config file")
|
||||
config = flag.String("config", "", "Path to config file")
|
||||
nextVersion = "0.0.1"
|
||||
version string
|
||||
commit string
|
||||
branch string
|
||||
)
|
||||
|
||||
func getVersion() string {
|
||||
if version == "" {
|
||||
return fmt.Sprintf("v%s~%s", nextVersion, commit)
|
||||
}
|
||||
return fmt.Sprintf("%s~%s", version, commit)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if glog.V(4) {
|
||||
@@ -26,8 +39,11 @@ func main() {
|
||||
mon := controller.NewMonitor(conf)
|
||||
srv := server.NewServer(conf.Agent.ListenAddr, mon)
|
||||
|
||||
glog.Infof("Starting GoCast %s", getVersion())
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
go srv.Serve(ctx)
|
||||
// catch interrupt
|
||||
shutdown := make(chan struct{})
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM)
|
||||
go func() {
|
||||
@@ -36,9 +52,10 @@ func main() {
|
||||
if sig == os.Interrupt || sig == syscall.SIGTERM {
|
||||
mon.CloseAll()
|
||||
cancel()
|
||||
shutdown <- struct{}{}
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
srv.Serve(ctx)
|
||||
<-shutdown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user