func()

in containers-starter-kit/SdkGoWrapper/server.go [48:77]


func (g gameProcess) OnProcessTerminate() {

        // Amazon GameLift will invoke this callback before shutting down an instance hosting this game server.
        // This will not happen on instances running game sessions and with fleet instance protection on, unless they are running on Spot and the instance is interrupted

        // First we tell GameLift we're ending the process
        server.ProcessEnding()

        // Send a termination signal to the parent process which is the wrapper.sh (this will terminate both this process, as well as the game server)
        // Get parent process ID
        ppid := os.Getppid()
        fmt.Printf("Parent Process ID: %d\n", ppid)

        // Get handle to parent process
        parent, err := os.FindProcess(ppid)
        if err != nil {
                fmt.Printf("Failed to find parent process: %v\n", err)
                return
        }
        // Send SIGKILL signal to parent
        fmt.Printf("Attempting to terminate parent process %d\n", ppid)
        err = parent.Signal(syscall.SIGKILL)
        if err != nil {
                fmt.Printf("Failed to terminate parent process: %v\n", err)
                return
        }

        // Terminate the wrapper (this should already happen when we terminate the parent process)
        os.Exit(0)
}