尝试在 rake 任务中启动 redis 和 resque 调度程序 [英] Trying to start redis and resque scheduler within a rake task
问题描述
我想从 rake 任务中启动 redis 和 redis-scheduler,因此我正在执行以下操作:
I want to start redis and redis-scheduler from a rake task so I'm doing the following:
namespace :raketask do
task :start do
system("QUEUE=* rake resque:work &")
system("rake redis:start")
system("rake resque:scheduler")
end
end
问题是 redis 在前台启动,然后这永远不会启动调度程序.如果它不会在后台启动(使用 &).调度程序必须在 redis 启动并运行后启动.
The problem is the redis starts in the foreground and then this never kicks off the scheduler. If It won't start in the background (using &). Scheduler must be started AFTER redis is up and running.
推荐答案
类似于 nirvdrum.如果 redis 尚未运行并接受连接,resque 工作人员将失败/退出.
similar to nirvdrum. The resque workers are going to fail/quit if redis isn't already running and accepting connections.
查看此要点以了解如何开始使用 monit(Linux 内容)的示例.
check out this gist for an example of how to get things started with monit (linux stuff).
Monit 允许一项服务依赖于另一项服务,并通过监控 .pid 文件确保它们保持活动状态.
Monit allows one service to be dependent on another, and makes sure they stay alive by monitoring a .pid file.
这篇关于尝试在 rake 任务中启动 redis 和 resque 调度程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!