Bisa / factorio-init

Factorio init script
MIT License
415 stars 82 forks source link

Don't wait on output when it isn't needed. The server may be paused. #134

Closed jadoc closed 5 years ago

jadoc commented 6 years ago

If the game server is paused, the log won't be updated with the magic strings generated by send_cmd, and the script will hang until the server in unpaused.

This is particularly deleterious in the event of a system shutdown while the game server is paused. The init script will hang trying to send players a helpful message and ultimately fail to ever send the TERM signal to the game server. Without the signal, the game server won't shutdown cleanly and won't save the current game state before the system goes down. The next time the server comes up, the game will be reverted to the last autosave.

This patch changes send_cmd so that it only waits for output if the -o option is passed, such as when a list of players is requested. When simply posting helpful messages to players, send_cmd will never block.

jadoc commented 6 years ago

I believe this fixes #136 .