Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SIGTERM by saving world and shutting down gracefully #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrisjoj
Copy link

@chrisjoj chrisjoj commented Apr 2, 2021

This is an initial attempt at a way to handle restarts and shutdowns gracefully as a resolution for #4

It does this by sending the 'exit' command to the TerrariaServer stdin which saves the world and shuts down the server.
It was based on https://github.com/alexivkin/terraria-server-container/blob/master/buildcontext/serverwatcher.sh

I've tested this with vanilla-1.4.2.1. If this looks like a good approach, I can do some testing with TShock to see if a similar approach would work for those images.

echo "Starting container, CMD: $CMD $@"
exec $CMD $@
(tail -f > /vanilla/console & $CMD $@ < console) &
Copy link

@meonkeys meonkeys Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console does not exist. Should that be /vanilla/console?

@meonkeys
Copy link

Nice, thanks! Works for me after fixing the one console typo on line 60. Some feedback:

  1. I'd appreciate some comments around the more esoteric Bash code (maybe what is esoteric Bash is just convention to a more experienced Bash programmer).
  2. After applying this patch I'm unable to attach to the container and issue commands to the server. We could maybe clean it up with more (named) pipes.

I could maintain this with great comments and a good deal of study or if it were in Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants