Closed eripa closed 1 year ago
I'm a bit surprised by this. If there's no explicit signal handling in the application, it should be shutting down already on sigterm. @ellie have you had any problems with your hosting?
I'll take a look in a bit, if need be it's not very hard to set up https://docs.rs/tokio/1.24.2/tokio/signal/unix/fn.signal.html with https://docs.rs/hyper/0.14.23/hyper/server/struct.Server.html#method.with_graceful_shutdown
Hey, thanks for the quick reply.
I tested this locally, and it seems to handle SIGTERM
fine (which is what Kubernetes use).
atuin server start
In another shell:
pkill -SIGTERM atuin
Then I get this in the first shell:
zsh: terminated atuin server start
I will try it in a regular Docker container too..
Yes, looks like it's a problem when the server runs in a container. I wonder if it has something to do with the container image configuration, will look at that.
Starting a local container like so (connecting to my kubernetes hosted postgreql):
docker run --platform=linux/amd64 --name atuin --rm -it --env=ATUIN_DB_URI=postgres://atuin:foo@10.244.3.77/atuin ghcr.io/ellie/atuin:latest server start
Trying to stop this container with a 30s time limit:
$ time docker stop -t 30 atuin
docker stop -t 30 atuin 0.04s user 0.02s system 0% cpu 30.155 total
take as many seconds as I let Docker wait..
I'll try to solve this
Hi 👋
when running the
atuin
server in a container, shutting down the container takes a long time. This is usually caused by the application not handling the SIGINT and SIGTERM signals and thus not shutting down on demand. Instead the system (Kubernetes/containerd, docker etc) eventually force terminate the application after a certain threshold of time.Unfortunately I'm not familiar with Rust so cannot submit a PR at this point, but from what I can tell the signal handling can be found in the Rust book:
https://rust-cli.github.io/book/in-depth/signals.html
Thanks for working on this awesome project!