# fly.toml to ensure commands before staging new apps

**URL:** <https://community.fly.io/t/fly-toml-to-ensure-commands-before-staging-new-apps/3877>\
**Category:** Questions / Help\
**Created:** [January 30, 2022, 6:18pm UTC](https://community.fly.io/t/fly-toml-to-ensure-commands-before-staging-new-apps/3877 "2022-01-30T18:18:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zane\_Milakovic](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/zane_milakovic/32/14527_2.png) [@Zane\_Milakovic](https://community.fly.io/u/Zane_Milakovic)\
**Post date:** [January 30, 2022, 6:18pm UTC](https://community.fly.io/t/fly-toml-to-ensure-commands-before-staging-new-apps/3877/1 "2022-01-30T18:18:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![FrequentFlyer](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@FrequentFlyer](https://community.fly.io/u/FrequentFlyer)\
**Post date:** [January 31, 2022, 3:06am UTC](https://community.fly.io/t/fly-toml-to-ensure-commands-before-staging-new-apps/3877/2 "2022-01-31T03:06:07Z")

</div>

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://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/blog/graceful-vm-exits-some-dials/#example-gracefully-shutdown-a-database-server)  
[https://fly.io/docs/reference/configuration/#runtime-options](https://fly.io/docs/reference/configuration/#runtime-options)

---

<div class="post-metadata">

**Author:** ![Zane\_Milakovic](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/zane_milakovic/32/14527_2.png) [@Zane\_Milakovic](https://community.fly.io/u/Zane_Milakovic)\
**Post date:** [January 31, 2022, 11:40am UTC](https://community.fly.io/t/fly-toml-to-ensure-commands-before-staging-new-apps/3877/3 "2022-01-31T11:40:38Z")

</div>

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