rails2 搭建异步环境 delay_job

config/environment.rb中添加
config.gem 'delayed_job', :version => '~>2.0.4'

config/initializers中创建
delay_job.rb内容如下:
silence_warnings>  Delayed::Job.const_set("MAX_ATTEMPTS", 3)
  Delayed::Job.const_set("MAX_RUN_TIME", 5.minutes)
end

安装
daemons 1.0.10
delayed_job  2.0.4


script/generate delayed_job
rake db:migrate

ruby  script/delayed_job start
nohup rake jobs:work &    //在后台开启守护进程


RAILS_ENV=production ruby script/delayed_job start   在production环境中,启用delay_job

issue.delay.create()    //create操作就会被加入到delay_job的表中

参考:https://github.com/collectiveidea/delayed_job/tree/v2.0

你可能感兴趣的:(rails2 搭建异步环境 delay_job)