I am using celery for async processing along with Heroku. I would like to be able to determine when Heroku sends SIGTERM prior to shutting down (when we are deploying new code, setting env vars, etc) in specific tasks. This will allow us to do any clean up on long running tasks greater than 10 seconds. I understand that we should strive for short idempotent tasks, but the data we are dealing with is too large to get to that level.
I have ran into the following doc: https://devcenter.heroku.com/articles/celery-heroku#using-remap_sigterm But the documentation is lacking, and without much context.
If someone could give me an example of how to handle this, I would greatly appreciate it!