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"部署后的命令。我怎么能正确地做到这一点?提前致谢!
答案 0 :(得分:0)
您可以在deploy.rb文件中运行shell命令。我通常会在下面执行以下操作" namespace:deploy do":
task :bundle_sidekiq, :roles => :app do
run "bundle exec sidekiq -d"
end
然后,在deploy.rb文件的末尾,执行以下操作,其中' foo'可以是任何任务,自定义或内置,来称呼它:
after 'deploy:foo', 'deploy:bundle_sidekiq'