'cap deploy'不会重启puma但是'cap deploy:restart'会重启

时间:2017-07-07 09:18:53

标签: ruby-on-rails capistrano

ruby2.2.4升级为2.4.1后,我开始面对此问题。

我的服务器会在cap deploy之后关闭,但在工作之后会执行cap deploy:restart

Capfile:

require 'capistrano/puma'
require 'capistrano/puma/jungle'

deploy.rb:

# ...

namespace :deploy do

  # 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

  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'
    end
  end

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      invoke 'puma:restart'
    end
  end

  before :starting,     :check_revision
  # after  :finishing,    :compile_assets
  after  :finishing,    :cleanup
  after  :finishing,    :restart

  # https://github.com/airbrake/airbrake#capistrano
  after :finished, 'airbrake:deploy'
end

任何有关如何诊断问题的帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

在gemfile中添加capistrano-puma gem(如果已添加则跳过):

gem 'capistrano3-puma' , group: :development

然后,通过在 Capfile 中添加以下行来安装Capistrano::Puma插件:

install_plugin Capistrano::Puma

这将包括所有必要的 puma 库。

另外,让你在deploy.rb文件中设置puma配置如下:

set :application,     'test-app'
...
...
set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"

现在,尝试部署您的应用。