Trying to start redis and resque scheduler within a rake task

坚强是说给别人听的谎言 提交于 2019-12-07 19:30:11

问题


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

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.


回答1:


similar to nirvdrum. The resque workers are going to fail/quit if redis isn't already running and accepting connections.

check out this gist for an example of how to get things started with monit (linux stuff).

Monit allows one service to be dependent on another, and makes sure they stay alive by monitoring a .pid file.




回答2:


That strikes me as not a great idea. You should have your redis server started via an init script or something. But, if you really want to go this way, you probably need to modify your redis:start task to use nohup and background the process so you can disconnect from the TTY and keep the process running.



来源:https://stackoverflow.com/questions/5316054/trying-to-start-redis-and-resque-scheduler-within-a-rake-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!