From 79baa31097c285be5756335bafc5923c2585ead7 Mon Sep 17 00:00:00 2001 From: Robert Bailey Date: Tue, 1 Feb 2022 22:03:18 -0800 Subject: [PATCH] Wait for the shutdown signal before having the simple game server exit. (#2463) --- examples/simple-game-server/Makefile | 2 +- examples/simple-game-server/main.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/simple-game-server/Makefile b/examples/simple-game-server/Makefile index ee5cc9b995..dc41ef7997 100644 --- a/examples/simple-game-server/Makefile +++ b/examples/simple-game-server/Makefile @@ -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 diff --git a/examples/simple-game-server/main.go b/examples/simple-game-server/main.go index 3e93b9f287..0257ff4e38 100644 --- a/examples/simple-game-server/main.go +++ b/examples/simple-game-server/main.go @@ -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 { @@ -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