mirror of
https://github.com/Octops/quake-kube.git
synced 2026-04-05 09:10:34 +00:00
Merge branch 'refactor/agones'
This commit is contained in:
@ -63,8 +63,10 @@ func NewCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
if opts.WithAgones {
|
||||
agones := &extensions.Agones{}
|
||||
if err := agones.Start(ctx, &s); err != nil {
|
||||
agones := &extensions.Agones{
|
||||
Server: &s,
|
||||
}
|
||||
if err := agones.Start(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -15,16 +15,19 @@ type Agones struct {
|
||||
sdk *sdk.SDK
|
||||
}
|
||||
|
||||
func (a *Agones) Start(ctx context.Context, server *quakeserver.Server) error {
|
||||
func (a *Agones) Start(ctx context.Context) error {
|
||||
if err := a.InitSdk(); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Server = server
|
||||
|
||||
if err := a.sdk.Ready(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go a.StartHeathCheck(ctx)
|
||||
go a.TrackStatus(ctx)
|
||||
|
||||
if err := server.Start(ctx); err != nil {
|
||||
if err := a.Server.Start(ctx); err != nil {
|
||||
return errors.Wrap(err, "failed to start server")
|
||||
}
|
||||
|
||||
@ -44,8 +47,10 @@ func (a *Agones) InitSdk() error {
|
||||
}
|
||||
|
||||
func (a *Agones) StartHeathCheck(ctx context.Context) {
|
||||
log.Print("[Agones] starting health check")
|
||||
tick := time.Tick(2 * time.Second)
|
||||
maxAttempts := 0
|
||||
|
||||
for {
|
||||
if err := a.sdk.Health(); err != nil {
|
||||
if maxAttempts > 5 {
|
||||
@ -53,6 +58,7 @@ func (a *Agones) StartHeathCheck(ctx context.Context) {
|
||||
}
|
||||
maxAttempts++
|
||||
} else {
|
||||
log.Print("[Agones] ping")
|
||||
maxAttempts = 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user