在capistrano部署期间延迟作业失败

时间:2012-08-04 09:04:17

标签: ruby-on-rails capistrano delayed-job activeadmin thinking-sphinx

我正在使用ActiveAdmin,capistrano进行部署,thinkng_sphinx进行搜索,并使用delayed_job在添加新记录后自动为ts运行reindex。

部署来自我的deploy.rb

before 'deploy:update_code', 'thinking_sphinx:stop'
after 'deploy:update',  'thinking_sphinx:index', 'thinking_sphinx:start'

after 'deploy:finalize_update', 'sphinx:symlink_indexes', "delayed_job:stop", "delayed_job:start"

问题是在部署期间运行此命令

 executing "RAILS_ENV=production /.../current/script/delayed_job stop"

我得到了

/.../shared/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:503:in `load_missing_constant'
Expected /.../releases/20120804075838/app/admin/users.rb to define Users (LoadError)
from /.../shared/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:192:in `block in const_missing'

...

这是app / admin / users.rb

ActiveAdmin.register ::User do
  index do   
    column :name
column "E-mail", :email
 end
end

我尝试将app / admin / users.rb重命名为app / admin / user.rb - 没有

但是如果我只是从服务器命令行运行:

RAILS_ENV=production script/delayed_job stop

一切正常

来自我的Gemfile

gem 'delayed_job'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'thinking-sphinx'
gem 'ts-delayed-delta', :require => 'thinking_sphinx/deltas/delayed_delta'
思考 - 狮身人面像(2.0.12) ts-delayed-delta(1.1.2) delayed_job(3.0.3) delayed_job_active_record(0.3.2) activeadmin(0.4.4)

1 个答案:

答案 0 :(得分:1)

在deploy.rb中尝试此操作。

require "delayed/recipes"

延迟食谱使用rails_env变量

set :rails_env,   "production"

# Delayed Job  
after "deploy:stop",    "delayed_job:stop"  
after "deploy:start",   "delayed_job:start"  
after "deploy:restart", "delayed_job:restart" 
after "deploy:update_code", "delayed_job:restart"

namespace :delayed_job do

desc "Stop the delayed_job process"
task :stop, :roles => :app do
  run "cd #{current_path}; script/delayed_job -e #{rails_env} stop"
end

desc "Start the delayed_job process"
task :start, :roles => :app do
  run "cd #{current_path}; script/delayed_job -e #{rails_env} start"
end

desc "Restart the delayed_job process"
task :restart, :roles => :app do
  run "cd #{current_path}; script/delayed_job -e #{rails_env} restart"
end
end