将Capistrano任务设置为仅在部署时运行,而不是部署:冷

时间:2009-05-15 22:53:40

标签: ruby-on-rails ruby installation capistrano deployment

我正在使用craken在我的aws机器实例上运行cron进程。我在Capistrano中定义了以下自定义任务:

namespace :craken do
  desc "Install raketab"
  task :install, :roles => :cron do
    set :rails_env, "production" unless exists?(:rails_env)
    set :env_args, (exists?(:env_args) ? env_args : "app_name=#{application} deploy_path=#{current_path}")
    run "cd #{current_path} && rake #{env_args} RAILS_ENV=#{rails_env} craken:install"
  end
  task :uninstall, :roles => :cron do
    set :rails_env, "production" unless exists?(:rails_env)
    set :env_args, (exists?(:env_args) ? env_args : "app_name=#{application} deploy_path=#{current_path}")
    run "cd #{current_path} && rake #{env_args} RAILS_ENV=#{rails_env} craken:uninstall"
  end
end

before "deploy:symlink", "craken:uninstall"
after "deploy:symlink", "craken:install"

问题是之前的“deploy:symlink”,“craken:uninstall”会导致deploy:cold在首次运行时失败,因为尚未安装craken raketab。如何将其配置为仅在部署而不是部署时运行:冷?是否有可以检查的环境变量?

谢谢!

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

快速破解,改变破解:卸载到

运行“cd#{current_path}&& rake#{env_args} RAILS_ENV =#{rails_env} craken:uninstall; true”

或者在部署时挂钩破解任务:更新