mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 02:34:42 +00:00
Update coordinator
This commit is contained in:
parent
769440f5ee
commit
57ba14a3e6
2 changed files with 43 additions and 0 deletions
43
cmd/coordinator/main.go
Normal file
43
cmd/coordinator/main.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/giongto35/cloud-game/pkg/coordinator"
|
||||
"github.com/giongto35/cloud-game/pkg/util/logging"
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
cfg := coordinator.NewDefaultConfig()
|
||||
cfg.AddFlags(pflag.CommandLine)
|
||||
|
||||
logging.Init()
|
||||
defer logging.Flush()
|
||||
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
|
||||
glog.Infof("Initializing coordinator server")
|
||||
glog.V(4).Infof("Coordinator configs %v", cfg)
|
||||
o := coordinator.New(ctx, cfg)
|
||||
if err := o.Run(); err != nil {
|
||||
glog.Errorf("Failed to run coordinator server, reason %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt)
|
||||
select {
|
||||
case <-stop:
|
||||
glog.Infoln("Received SIGTERM, Quiting Coordinator")
|
||||
o.Shutdown()
|
||||
cancelCtx()
|
||||
}
|
||||
}
|
||||
BIN
docs/img/coordinator.png
vendored
Normal file
BIN
docs/img/coordinator.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Loading…
Add table
Add a link
Reference in a new issue