MatchTerminate function is not getting called in nakama 2.11.1


after nakama upgrade from 2.7.0 to 2.11.1 , MatchTerminate function is not getting called when server shutdown , it was working fine in 2.7.0 .

i am talking about

MatchTerminate(ctx context.Context, _ runtime.Logger, _ *sql.DB, _ runtime.NakamaModule, dispatcher runtime.MatchDispatcher, tick int64, state interface{}, graceSeconds int) interface{} {

i have tested several times in Google App Engine by redeploying , it was working fine in 2.7.0 .

what cloud be the reason for this?

thanks in advance,

We’ve tested this extensively and cannot reproduce the issue. Please share a minimal example of Go code with a match handler that exhibits the behaviour.

I should also note that the --shutdown_grace_sec option in the server observes SIGTERM/SIGKILL events but will not execute if some other process (like an OOM killer) stops the game server with a “kill -9” signal. This is not a graceful termination and impossible to prevent.

A final note on how graceful match handler termination works in Nakama. The time in seconds is the maximum length of time before the game server will shutdown. If all all match handlers clean up and stop quicker the server will stop sooner.

Maximum number of seconds to wait for the server to complete work before shutting down. If 0 the server will shut down immediately when it receives a termination signal. Default value is 0 .

Hope this helps.

thank you very much for your reply.

we are using match handler , and it’s structure look like

type Match struct {
logger     *Logger
Config     *Conf
Updater    Service
time1      time.Time
time2      time.Time
ch         chan struct{}

Logger is wrapper on zap.Logger with mutex

Conf is structure with some string fields 

Service  is an interface ( has some custom fields, is a struct of same logger and some custom fields )

we are implementing

  MatchInit, MatchJoinAttempt, etc on this Match

as i said , this exact same structure is not working after nakama upgrade , but it was working with previous version

we are using

shutdown_grace_sec: 90

waiting for your reply and thanks in advance,

This was solved out of the forums. The issue related to the use of bash versus sh in launch scripts used to trap SIGTERM/SIGKILL OS signals to activate graceful shutdown.