# MatchTerminate function is not getting called in nakama 2.11.1

**URL:** <https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643>\
**Category:** Local Setup\
**Created:** [April 16, 2020, 4:35am UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643 "2020-04-16T04:35:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JunaidMkdn](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/junaidmkdn/32/194_2.png) [@JunaidMkdn](https://forum.heroiclabs.com/u/JunaidMkdn)\
**Post date:** [April 16, 2020, 4:35am UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643/1 "2020-04-16T04:35:08Z")

</div>

hello,

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

```auto
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,  
Junaid

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [April 17, 2020, 12:14pm UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643/2 "2020-04-17T12:14:50Z")

</div>

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` .

[https://heroiclabs.com/docs/install-configuration/#server-configuration](https://heroiclabs.com/docs/install-configuration/#server-configuration)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![JunaidMkdn](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/junaidmkdn/32/194_2.png) [@JunaidMkdn](https://forum.heroiclabs.com/u/JunaidMkdn)\
**Post date:** [April 19, 2020, 4:34am UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643/3 "2020-04-19T04:34:56Z")

</div>

@novabyte,  
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,

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [May 16, 2020, 4:55pm UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643/4 "2020-05-16T16:55:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [May 16, 2020, 4:55pm UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643/5 "2020-05-16T16:55:28Z")

</div>



---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [May 16, 2020, 4:55pm UTC](https://forum.heroiclabs.com/t/matchterminate-function-is-not-getting-called-in-nakama-2-11-1/643/6 "2020-05-16T16:55:37Z")

</div>


