Skip to content

Implemented graceful shutdown and fixed various TUI bugs

Ben Wallis requested to merge xvar/sigint-graceful-shutdown into master

This MR introduces a graceful shutdown mechanic, which when initiated begins counting down for the configured grace period, sending a warning message to all connected players every 30 seconds, and then every 1 second in the last 10 seconds of the grace period.

The shutdown can be triggered either by sending veloren-server-cli the SIGUSR1 signall on Linux, or the shutdown <seconds> TUI command. The SIGUSR1 signal was chosen to avoid interfering with SIGINT which is generated on Ctrl+C on Linux and Windows, and SIGTERM which still kills the server as expected.

In order for this change to work correctly, the docker-compose.yml file has had the --stop-timeout 130s argument added in order to make it wait for the 2 minute grace period + 10 seconds to expire before force killing the server. https://containrrr.dev/watchtower/arguments/#wait_until_timeout

  • Implemented graceful shutdown on SIGUSR1 signal.
  • Added ShutdownCoordinator module to veloren-server-cli
  • Added shutdown <seconds> TUI command.
  • Added abortshutdown TUI command.
  • Added update_shutdown_grace_period_secs and update_shutdown_message server settings
  • Fixed a bug in TUI that caused a panic on quit in basic mode on windows.
  • Fixed a bug in TUI that meant commands with 1 or more arguments printed an error message in the console
  • Moved TUI panic hook to main.rs for better visibility
  • Added Watchtower LABEL in server-cli\Dockerfile to configure Watchtower to use SIGUSR1 for shutdowns https://containrrr.dev/watchtower/stop-signals/
  • Added --stop-timeout 130s argument to watchtower in server-cli\docker-compose.yml
  • By opening this merge request, you agree to release your code and all other changes under the GPL 3 license and to abide by the terms set by this license.
  • Migrations have been added if applicable
  • Significant changes of this merge request have been added to the changelog.
Edited by Ben Wallis

Merge request reports