question

thibautpetit avatar image
thibautpetit asked

Cannot shutdown linux process on Unity

I have a Linux server build running on docker with Unity. Whatever I try, I cannot get the container to stop. So in the dashboard, the server will always stay "active". Here are the methods I tried:

Process.GetCurrentProcess().Close() ; does nothing Process.GetCurrentProcess().Kill(); returns NotSupportedException: This platform does not support file handle duplication. Process.GetCurrentProcess().Stop(); does nothing Application.Quit(); seems to stop unity but does not stop the docker process Environment.Exit( 0 ); stops the execution but doesn't clear the container

How can I get the server to terminate ?

unity3dCustom Game Serversmultiplayer
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dimitris Gkanatsios avatar image Dimitris Gkanatsios commented ·

Technically, the container stops when the process with PID 1 exits. How does your container start? Or better, what's the CMD/ENTRYPOINT commands in your Dockerfile?

0 Likes 0 ·
thibautpetit avatar image thibautpetit Dimitris Gkanatsios commented ·

Here's the CMD in mu dockerfile : CMD ["/game/Server.x86_64"]

0 Likes 0 ·
thibautpetit avatar image thibautpetit Dimitris Gkanatsios commented ·

Here's the dockerfile

FROM ubuntu:18.04

RUN apt update RUN apt install -y --reinstall ca-certificates

ADD . . CMD ["/game/Server.x86_64"]

0 Likes 0 ·

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

In the common scenario, Application.Quit() in Unity should terminate the game server instance, then according to the documentation: Lifecycle of a multiplayer server - PlayFab | Microsoft Learn, MPS will remove the container/process running this game server. If your server instance stays in active after you call the Application.Quit() method for a while, could you please provide your TitleId and SessionId for us to investigate. Also, you can call Shutdown Multiplayer Server API to terminate the server instance manually.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

thibautpetit avatar image thibautpetit commented ·

Title id : 41A84 Session id : 3CBBC7BF-73BC-466E-9CD8-7C84C3C44FA7

The build is currently running after an application.quit has been called

I have yet to try the "Shutdown Multiplayer Server API", but when I shutdown the server via the servers dashboard, the build will take 15 minutes to be forcefully shutdown

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha thibautpetit commented ·

Thank you for your information. I was wondering how do you know that you have called the Application.quit() method on the server? Can you provide some logs? Also, you can try Connect directly to debug game servers, then you can use the console of the operating system to monitor your game servers.

0 Likes 0 ·
thibautpetit avatar image thibautpetit Xiao Zha commented ·

Currently the servers are set to shutdown after they were set to active (via matchmaking), and no player has connected to them. Here since I opened a server via the "request server" button on the dashboard, and no player connected to it, it should shut itself down after a few moments

Here are the logs from the server

[SERVER] Some players have not connected, shutting down [SERVER] Server stopped, application will shut down in 3 seconds Timer:1.000495 - Max:1 PlayFab.PlayFabMultiplayerAgentView:LateUpdate()

state: PlayFab.MultiplayerAgent.Model.HeartbeatRequest, payload: {"CurrentGameState":"Active","CurrentGameHealth":"Healthy","CurrentPlayers":[]}

Operation: Continue, Maintenance:, State: Active PlayFab.PlayFabMultiplayerAgentAPI:ProcessAgentResponse(HeartbeatResponse)

[SERVER] Quitting application UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

//------Here is where the Application.Quit() has been called -------- //

[SERVER] Post application quit UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

77.13 PlayFabMultiplayerAgentView destroyed PlayFab.PlayFabMultiplayerAgentView:OnDestroy()

Curl error 42: Callback aborted

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.