[![Gem Version](https://badge.fury.io/rb/resque-heroku-signals.svg)](https://badge.fury.io/rb/resque-heroku-signals)
[![Ruby](https://github.com/iloveitaly/resque-heroku-signals/actions/workflows/ci.yml/badge.svg)](https://github.com/iloveitaly/resque-heroku-signals/actions/workflows/ci.yml)
# resque-heroku-signals
This gem patches resque to be compatible with the Heroku platform. Specifically it
modifies the UNIX signaling logic to be compatible with the Heroku worker shutdown process.
[Read this GitHub comment for more context & details.](https://github.com/resque/resque/issues/1559)
The version of this gem corresponds to the version of Resque that it is compatible with.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'resque-heroku-signals'
```
Since this gem monkeypatches the Heroku worker the `gemspec` is locked to a `x.x.x` version of Resque to ensure the monkeypatched logic is compatible with any changes in the original Resque logic. 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
```
* `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: important log messages could fail to push to stdout during the worker shutdown process:
```ruby
$stdout.sync = true
```
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
没有合适的资源?快使用搜索试试~ 我知道了~
补丁resque与Heroku进程信号兼容_Ruby_Shell_下载.zip
共16个文件
yml:3个
rb:3个
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 183 浏览量
2023-04-27
10:51:38
上传
评论
收藏 9KB ZIP 举报
温馨提示
补丁resque与Heroku进程信号兼容_Ruby_Shell_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
补丁resque与Heroku进程信号兼容_Ruby_Shell_下载.zip (16个子文件)
resque-heroku-signals-master
lib
resque-heroku-signals.rb 1KB
Rakefile 117B
.rspec 31B
.ruby-version 6B
.github
funding.yml 174B
dependabot.yml 211B
workflows
ci.yml 545B
LICENSE.txt 1KB
spec
resque
heroku_spec.rb 3KB
spec_helper.rb 279B
bin
console 348B
setup 131B
Gemfile 66B
.gitignore 142B
resque-heroku-signals.gemspec 1KB
README.md 3KB
共 16 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功