README.md in resque-heroku-signals-1.27.4.2 vs README.md in resque-heroku-signals-1.27.4.3

- old
+ new

@@ -13,12 +13,20 @@ ```ruby gem 'resque-heroku-signals' ``` -Since this gem monkeypatches the Heroku worker the `gemspec` is locked to a `x.x.x` version of Resque. Issue a PR if this is not compatible with the version of resque you are using. +Since this gem monkeypatches the Heroku worker the `gemspec` is locked to a `x.x.x` version of Resque. Issue a PR if this is not compatible with the version of resque you are using. +## Determining When a Process Will Shutdown + +Heroku sends a `TERM` signal to a process before hard killing it. If your job communicates with slow external APIs, you may want to make sure you have enough time to receive and handle the response from the external system before executing the API requests. + +Ideally, using an idempotency key with each external API request is the best way to ensure that a given API request only runs. However, depending on your application logic this may not be practical and knowing if a process will be terminated in less than 30s by Heroku is a useful tool. + +Use `Resque.heroku_will_terminate?` to determine if Heroku will terminate your process within 30s. + ## Example Procfile ``` worker: env QUEUE=* TERM_CHILD=1 INTERVAL=0.1 RESQUE_PRE_SHUTDOWN_TIMEOUT=20 RESQUE_TERM_TIMEOUT=8 bundle exec rake resque:work ``` @@ -26,10 +34,10 @@ * `RESQUE_PRE_SHUTDOWN_TIMEOUT` time a job has to finish up before the `TermException` exception is raised * `RESQUE_TERM_TIMEOUT` time the job has to cleanup & save state * Total shutdown time should be less than 30s. This is the time [Heroku gives you to cleanup before a `SIGKILL` is issued](https://devcenter.heroku.com/articles/dynos#shutdown) * `INTERVAL` seconds to wait between jobs -Also, make you don't buffer logs: import log messages could fail to push to stdout during the worker shutdown process: +Also, make you don't buffer logs: important log messages could fail to push to stdout during the worker shutdown process: ```ruby $stdout.sync = true ```