OpenFactorioServerManager / factorio-server-manager

A tool to help manage Factorio multiplayer servers including mods and save games.
MIT License
541 stars 130 forks source link

Fix server reported stopped to early #286

Closed jannaahs closed 2 years ago

jannaahs commented 3 years ago

Possible fix for #239

The output of factorio when shutting down the server looks like:

33.394 Received SIGINT, shutting down 33.408 Quitting: signal. 33.408 Info MainLoop.cpp:415: Saving map as D:\xampp\htdocs\Factorio_x64_1.1.6\Factorio_1.1.6\saves\asd.zip 33.466 Info MainLoop.cpp:426: Saving progress: 0.250000% 33.471 Info MainLoop.cpp:426: Saving progress: 100.000000% 33.488 Info ServerMultiplayerManager.cpp:113: Disconnecting multiplayer connection. 33.488 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(InGame) to(DisconnectingScheduled) 33.537 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(DisconnectingScheduled) to(Disconnecting) 33.584 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(Disconnecting) to(Disconnected) 33.584 Info ServerMultiplayerManager.cpp:140: Quitting multiplayer connection. 33.584 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(Disconnected) to(Closed)

The last line ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(Disconnected) to(Closed) is used to detect a successful shut down.

knoxfighter commented 3 years ago

That is not the last line that is printed. That line is called half a second before shutdown is finished (for me at least).

My output shows a goodbye line as last one, why not use that one?

2021/07/01 15:17:23 Factorio Server:   11.206 Received SIGINT, shutting down
2021/07/01 15:17:23 Factorio Server:   11.206 Quitting: signal.
2021/07/01 15:17:23 Factorio Server:   11.206 Info MainLoop.cpp:417: Saving map as /opt/factorio/saves/test.zip
2021/07/01 15:17:23 Factorio Server:   11.253 Info MainLoop.cpp:428: Saving progress: 0.250000%
2021/07/01 15:17:23 Factorio Server:   11.258 Info MainLoop.cpp:428: Saving progress: 100.000000%
2021/07/01 15:17:23 Factorio Server:   11.279 Info ServerMultiplayerManager.cpp:113: Disconnecting multiplayer connection.
2021/07/01 15:17:23 Factorio Server:   11.279 Info ServerMultiplayerManager.cpp:780: updateTick(0) changing state from(InGame) to(DisconnectingScheduled)
2021/07/01 15:17:23 Factorio Server:   11.313 Info ServerMultiplayerManager.cpp:780: updateTick(0) changing state from(DisconnectingScheduled) to(Disconnecting)
2021/07/01 15:17:23 Factorio Server:   11.346 Info ServerMultiplayerManager.cpp:780: updateTick(0) changing state from(Disconnecting) to(Disconnected)
2021/07/01 15:17:23 Factorio Server:   11.346 Info ServerMultiplayerManager.cpp:140: Quitting multiplayer connection.
2021/07/01 15:17:23 Factorio Server:   11.346 Info ServerMultiplayerManager.cpp:780: updateTick(0) changing state from(Disconnected) to(Closed)
2021/07/01 15:17:24 Factorio Server:   11.528 Info UDPSocket.cpp:218: Closing socket
2021/07/01 15:17:24 Factorio Server:   11.528 Info UDPSocket.cpp:248: Socket closed
2021/07/01 15:17:24 Factorio Server:   11.528 Info UDPSocket.cpp:218: Closing socket
2021/07/01 15:17:24 Factorio Server:   11.598 Info UDPSocket.cpp:218: Closing socket
2021/07/01 15:17:24 Factorio Server:   11.598 Info UDPSocket.cpp:248: Socket closed
2021/07/01 15:17:24 Factorio Server:   11.638 Goodbye
jannaahs commented 3 years ago

I havn't seen the "Goodbye" in my logs using the latest version of factorio for windows. The log ends with the line I used. This might be an issue with the windows implementation of the server.

Here is my complete log of the shutdown procedure with windows:

2021/07/01 21:32:26 Sent SIGINT to Factorio process. Factorio shutting down... 2021/07/01 21:32:26 Factorio Server: 5.157 Received SIGINT, shutting down 2021/07/01 21:32:26 Factorio Server: 5.162 Quitting: signal. 2021/07/01 21:32:26 Factorio Server: 5.162 Info MainLoop.cpp:417: Saving map as D:\xampp\htdocs\Factorio_x64_1.1.35\Factorio_1.1.35\saves\test.zip 2021/07/01 21:32:26 Factorio Server: 5.210 Info MainLoop.cpp:428: Saving progress: 0.250000% 2021/07/01 21:32:26 Factorio Server: 5.212 Info MainLoop.cpp:428: Saving progress: 100.000000% 2021/07/01 21:32:26 Factorio Server: 5.234 Info ServerMultiplayerManager.cpp:113: Disconnecting multiplayer connection. 2021/07/01 21:32:26 Factorio Server: 5.234 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(InGame) to(DisconnectingScheduled) 2021/07/01 21:32:26 Factorio Server: 5.268 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(DisconnectingScheduled) to(Disconnecting) 2021/07/01 21:32:26 Factorio Server: 5.316 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(Disconnecting) to(Disconnected) 2021/07/01 21:32:26 Factorio Server: 5.316 Info ServerMultiplayerManager.cpp:140: Quitting multiplayer connection. 2021/07/01 21:32:26 Factorio Server: 5.316 Info ServerMultiplayerManager.cpp:783: updateTick(0) changing state from(Disconnected) to(Closed) 2021/07/01 21:32:26 new state, will also send to correct room 2021/07/01 21:32:36 Factorio server stopped 2021/07/01 21:32:36 Factorio process exited with error: exit status 1 2021/07/01 21:32:36 Error starting Factorio server: exit status 1

On my linux machine the "Goodbye" is included.

Jul 01 21:36:12 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:12 Factorio Server: 417378.446 Info ServerMultiplayerManager.cpp:780: updateTick(83231826) changing state from(InGame) to(D> Jul 01 21:36:12 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:12 Factorio Server: 417378.480 Info ServerMultiplayerManager.cpp:780: updateTick(83231826) changing state from(Disconnectin> Jul 01 21:36:12 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:12 Factorio Server: 417378.513 Info ServerMultiplayerManager.cpp:780: updateTick(83231826) changing state from(Disconnectin> Jul 01 21:36:12 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:12 Factorio Server: 417378.513 Info ServerMultiplayerManager.cpp:140: Quitting multiplayer connection. Jul 01 21:36:12 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:12 Factorio Server: 417378.513 Info ServerMultiplayerManager.cpp:780: updateTick(83231826) changing state from(Disconnected> Jul 01 21:36:14 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:14 Factorio Server: 417380.106 Info UDPSocket.cpp:218: Closing socket Jul 01 21:36:14 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:14 Factorio Server: 417380.106 Info UDPSocket.cpp:248: Socket closed Jul 01 21:36:14 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:14 Factorio Server: 417380.230 Goodbye Jul 01 21:36:14 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:14 Factorio process exited with error: exit status 1 Jul 01 21:36:14 v22019032862584256 factorio-server-manager[101333]: 2021/07/01 21:36:14 Error starting Factorio server: exit status 1

TL;DR

Using the line I did seems to be the only way to work under linux and windows.

jannaahs commented 3 years ago

@knoxfighter and I have discussed the backend changes for recognized factorio as stopped after process is killed:

I have also added some aprovements for the frontend.

This improves the user experience by providing direct feedback after clicking those buttons and reduce the amount of request to the backend.

jannaahs commented 2 years ago

The last commit should be on another branch. Now it's here and will fix #287 anyways. 😄

jannaahs commented 2 years ago

I switched to Linux and got some trouble building the frontend. Therefore, I've updated the frontend dependencies in a separate branch.

I'll to wait until #293 is merged.

jannaahs commented 2 years ago

@knoxfighter can you check the latest changes? It should fix the ui on the develop branch.

Mattie112 commented 2 years ago

@knoxfighter can you check the latest changes? It should fix the ui on the develop branch.

If I download latest docker image tagged fix-server-reported-stopped-to-early the UI works fine for me (after a hard refresh)

Mattie112 commented 2 years ago

Can this please be merged in the develop branch?

(and/or @jannaahs can you merge this with develop so at least a new docker image is tagged :) )