fly.toml to ensure commands before staging new apps

This may be a feature request. But I was curious if there was a way to conduct a command to be called, after a health check passes, but before the retiring container is removed.

For example if your running KeyDB, it saves to the persistent volume every ~5 minutes or 100 changes.

If a deploy occurs, does this mean that I don’t have the latest copy of data (5 minute window), because it was not written to the mounted volume?

In the KeyDB docs they say you either need to call SAVE or SHUTDOWN to ensure persistence.

Is there a place to hook in and ensure either can be called before ending lifecycle?

Hey,

In your fly.toml, you can use SIGTERM as your kill_signal.
Additionally, a longer kill_timeout, if required, should help.
Then, you can tighten down kill_timeout to get as close to zero as possible, to not wait around for long.

https://docs.keydb.dev/docs/signals/#handling-of-sigterm
https://fly.io/blog/graceful-vm-exits-some-dials/#example-gracefully-shutdown-a-database-server
https://fly.io/docs/reference/configuration/#runtime-options

2 Likes

This is exactly what I was looking for @FrequentFlyer. Appreciate it!