1

我正在使用 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'

Thinking-sphinx (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)

4

1 回答 1

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
于 2012-09-07T12:15:55.953 回答