- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设这是我的 worker :
class FooWorker
@queue = :foo
def self.perform
User.all.each do |u|
...
Do Long Operations (Unsafe to kill)
...
# Here it's safe to break the worker and restart
end
end
end
我正在使用 Resque Scheduler 排队,这是我的 Bluepill conf:
...
app.process(process_name) do |process|
process.group = "resque"
process.start_command = "rake environment resque:work QUEUE=foo RAILS_ENV=production"
...
process.stop_signals = [:quit, 5.seconds, :term, 1.minute, :kill]
process.daemonize = true
process.start_grace_time = 30.seconds
process.stop_grace_time = 80.seconds
process.monitor_children do |child_process|
child_process.stop_command = "kill -QUIT {{PID}}"
child_process.checks :mem_usage, :every => 30.seconds, :below => 500.megabytes, :times => [3,4], :fires => :stop
end
end
....
我想让 Bluepill 或 Resque 等到它到达“安全” block 以重新启动或关闭。如何实现?
最佳答案
这样试试:
1) 使用 new_kill_child
设置 resque 以在 TERM/INT 上优雅地杀死 child 通过在启动时设置 TERM_CHILD
和 RESQUE_TERM_TIMEOUT
env 变量的方法:
process.start_command = "rake environment resque:work QUEUE=foo RAILS_ENV=production TERM_CHILD=1 RESQUE_TERM_TIMEOUT=20.0"
RESQUE_TERM_TIMEOUT
的默认值为 4 seconds .
这将使 resque 向 child 发送 TERM 信号,等待 RESQUE_TERM_TIMEOUT
,如果 child 仍在运行,则终止它。一定要
a) 将此超时设置得足够大,以便您的关键部分结束,
b) 在 process.stop_signals
中将 Bluepill TERM 超时配置为比 RESQUE_TERM_TIMEOUT
稍大一点,以便在等待子进程结束临界区时不杀死 worker。
2) 处理子进程中的 TERM 信号以正常停止:
class FooWorker
class << self
attr_accessor :stop
end
@queue = :foo
def self.perform
User.all.each do |u|
...
Do Long Operations (Unsafe to kill)
...
# Here it's safe to break the worker and restart
return if FooWorker.stop
end
end
end
trap('TERM') do
FooWorker.stop = true
end
关于resque - 如何让 Bluepill 仅在达到安全状态后才重启 Resque worker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18424290/
我用coffee-resque创建了一些worker,并尝试使用resque-web的ruby版本查看worker,但只看到间歇性的worker闪进闪出。 我注意到咖啡风格在暂停时会取消对 worke
假设这是我的 worker : class FooWorker @queue = :foo def self.perform User.all.each do |u| ..
我对 resque 很陌生,但它看起来非常适合我的需求。 实际上,我正在尝试设置一个简单的测试应用程序,例如: require 'resque' require 'resque/job_with_st
我正在使用 Resque 和 Resque 调度程序,但是当我输入命令时 resque-web它没有运行。而是提示错误: bash: resque-web: command not found So
我正在使用 ruby on rails 构建一个 webapp,它需要在后台运行 C++ exe 程序。我为此比较了 3 个最常用的 gem(Delayed_Jobs、Resque、Sidekiq
我想知道 resque-scheduler 是否需要一个 resque 实例来运行特定队列中的作业,或者 resque-scheduler 必须使用 resque:work 任务。 提前致谢。 最佳答
我正在使用 Resque、Resque-Status 和 Resque-Retry 来处理 bkg 作业。以下是一个示例作业。它针对 4-5 个模型执行查询。现在我想尝试使用 Sidekiq它以其超过
我正在开发一个使用 resque 的 rails 应用程序和 resque-scheduler 安排电子邮件发送。 有没有办法获得所有预定作业的列表,或者更好的具有特定参数的作业列表? 我尝试了一些类
将 Resque 与 Redis 结合使用 我一直收到 Redis 的 OOM 命令在使用内存时不允许 > 'maxmemory' 错误。现在很明显,我似乎应该将 redis 的内存从当前的 500M
此外,管理内置“管理结构”(如标题中的结构)的 Resque 的最佳实践是什么?我应该用 jedis.del(String key) 或类似的东西清除它们吗? 最佳答案 resque:failed 是
我有 resque-scheduler 在 Rails 应用程序中运行良好。现在我需要能够从队列中跟踪状态并删除作业。我简要地查看了 resque-status,据我所见,如果我能让它与 resque
我都关注了 instructions on resque-scheduler repo在 resque-web 界面上显示“延迟”和“计划”选项卡,但什么也没有! 这是进口的 gem : gem 'r
我已经为我的应用程序设置了 Resque.redis.namespace,现在 resque-web 不再显示工作人员和队列。 有什么方法可以让 resque-web 知道 redis.namespa
我一直试图让 Resque(使用 Resque 服务器)和 RedisToGo 在 heroku(cedar)上工作一段时间,但我一直遇到这个错误: Redis::CannotConnectError
我在 resque 工作中遇到了一个奇怪的问题,我想知道是否有其他人遇到过。 我们在 jruby 1.6.2 下运行 resque 我们有一个长时间 运行任务,它从各种 URL 下载一堆文件,使用 F
我刚刚看了这个关于 Resque 的惊人的 railscast .在我启动 redis 服务器并启动 workers 之后: rake environment resque:work QUEUE="*
我使用 resque-history 插件来监控已完成的任务。 首先,我将这个字符串 require 'resque-history/server' 包含到路由文件中,然后我在仪表板中看到了新的历史记
我需要启动 4 个 resque 工作人员,所以我使用了以下命令 bundle exec rake environment resque:workers RAILS_ENV=production CO
我有几个 Resque 作业在运行,每个都在一个单独的终端窗口中启动,如下所示: QUEUE=queue_1 rake environment resque:work QUEUE=queue_2 ra
我有以下代码。它的工作是根据通过浏览器(使用 Sinatra)提供的数据发送电子邮件。它会在 20 秒后向给定的地址发送一封电子邮件。当我运行该程序时,它会立即发送电子邮件,而无需等待时间。谁能帮我解
我是一名优秀的程序员,十分优秀!