2015-03-13 64 views
0

存在對Capistrano的下面的代碼部署:如何在通過Capistrano部署後執行「命令行」實用程序?

namespace :deploy do 

    desc 'Restart application' 
    task :restart do 
    on roles(:app), in: :sequence, wait: 5 do 
     # Your restart mechanism here, for example: 
     execute :mkdir, '-p', "#{ release_path }/tmp" 
     execute :touch, release_path.join('tmp/restart.txt') 
    end 
    end 

    after :publishing, :restart 

    after :restart, :clear_cache do 
    on roles(:web), in: :groups, limit: 3, wait: 10 do 
     # Here we can do anything such as: 
     # within release_path do 
     # execute :rake, 'cache:clear' 
     # end 
    end 
    end 

end 

我需要部署後執行「捆綁EXEC sidekiq -d」命令。我如何正確地做到這一點?提前致謝!

+1

大概[this](https://github.com/seuros/capistrano-sidekiq)可以幫助你! – GeekRiky 2015-03-13 06:46:37

回答

0

您可以在deploy.rb文件中運行shell命令。我通常不喜歡這樣下面的「命名空間:部署做」:

task :bundle_sidekiq, :roles => :app do 
    run "bundle exec sidekiq -d" 
end 

然後,在你的deploy.rb文件的末尾,請執行下列操作,其中「富」可以是任何任務,自定義或內置在,稱之爲:

after 'deploy:foo', 'deploy:bundle_sidekiq' 
相關問題