gpt4 book ai didi

ruby-on-rails - Capistrano Rails部署后重新启动服务

转载 作者:行者123 更新时间:2023-12-03 00:30:45 25 4
gpt4 key购买 nike

我的网站已与Capistrano一起部署。部署完成后,如何才能使delay_job和elasticsearch重新启动?

最佳答案

您需要在delayed_job.rake中创建lib/capistrano/tasks


# delayed_job.rake
namespace :delayed_job do
def args
fetch(:delayed_job_args, '')
end

def delayed_job_roles
fetch(:delayed_job_server_role, :app)
end

desc 'Stop the delayed_job process'
task :stop do
on roles(delayed_job_roles) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :'bin/delayed_job -n 1', :stop
end
end
end
end

desc 'Start the delayed_job process'
task :start do
on roles(delayed_job_roles) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :'bin/delayed_job -n 1', args, :start
end
end
end
end

desc 'Restart the delayed_job process'
task :restart do
on roles(delayed_job_roles) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :'bin/delayed_job -n 1', args, :restart
end
end
end
end
end

并在您的config / deploy.rb中添加以下行

after :publishing, :restart

task :restart do
invoke 'delayed_job:restart'
end

关于ruby-on-rails - Capistrano Rails部署后重新启动服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61468902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com