Skip to content

Commit

Permalink
Wait for the shutdown signal before having the simple game server exi…
Browse files Browse the repository at this point in the history
…t. (#2463)
  • Loading branch information
roberthbailey authored Feb 2, 2022
1 parent 0dbaaff commit 79baa31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/simple-game-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ WITH_WINDOWS=1

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
server_tag = $(REGISTRY)/simple-game-server:0.9
server_tag = $(REGISTRY)/simple-game-server:0.10
ifeq ($(WITH_WINDOWS), 1)
server_tag_linux_amd64 = $(server_tag)-linux_amd64
else
Expand Down
11 changes: 6 additions & 5 deletions examples/simple-game-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ func shutdownAfterNAllocations(s *sdk.SDK, readyIterations, shutdownDelaySec int
}

log.Println("Moving Game Server to Shutdown")
shutdownErr := s.Shutdown()
if shutdownErr != nil {
if shutdownErr := s.Shutdown(); shutdownErr != nil {
log.Fatalf("Could not shutdown game server: %v", shutdownErr)
}
log.Println("Exiting Game Server")
os.Exit(0)
// The process will exit when Agones removes the pod and the
// container receives the SIGTERM signal
return
}(remainingIterations)
}
}); err != nil {
Expand Down Expand Up @@ -450,7 +450,8 @@ func exit(s *sdk.SDK) {
if shutdownErr != nil {
log.Printf("Could not shutdown")
}
os.Exit(0)
// The process will exit when Agones removes the pod and the
// container receives the SIGTERM signal
}

// gameServerName returns the GameServer name
Expand Down

0 comments on commit 79baa31

Please sign in to comment.