Warning: file_put_contents(/datas/wwwroot/jiajiahui/core/caches/caches_template/2/default/show.php): failed to open stream: Permission denied in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 55

Warning: chmod(): Operation not permitted in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 56
如何在通过Capistrano部署后执行“命令行”实用程序? - 源码之家

如何在通过Capistrano部署后执行“命令行”实用程序?

问题描述:

存在对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

您可以在deploy.rb文件中运行shell命令。我通常不喜欢这样下面的“命名空间:部署做”:

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

然后,在你的deploy.rb文件的末尾,请执行下列操作,其中“富”可以是任何任务,自定义或内置在,称之为:

after 'deploy:foo', 'deploy:bundle_sidekiq'