capistrano-puma: puma:restart related to deploy doesn't work

capistrano (3.8.2) capistrano3-puma (3.1.0) capistrano-rbenv (2.1.1) capistrano-bundler (1.2.0) puma (3.9.1)

In config/deploy.rb:

set :rbenv_map_bins, %w(rake gem bundle ruby rails puma pumactl sidekiq sidekiqctl)

When I deploy, puma:restart says it went ok:

02:20 puma:restart
      01 $HOME/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/user/app/shared/tmp/pids/puma.state -F /home/user/app/shared/config/puma.rb restart
      01 Command restart sent success
    ✔ 01 user@server 0.780s

but the app didn’t restart, and in the log there is this error:

==> log/puma_error.log <==
/home/user/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem puma (>= 0.a) (Gem::GemNotFoundException)
  from /home/user/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems.rb:298:in `activate_bin_path'
  from /home/user/app/shared/bundle/ruby/2.4.0/bin/puma:22:in `<main>'

Instead, if I restart manually running cap puma:restart after the deploy it works:

> cap stage puma:restart
00:00 puma:start
      using conf file /home/user/app/shared/config/puma.rb
      01 $HOME/.rbenv/bin/rbenv exec bundle exec puma -C /home/user/app/shared/config/puma.rb --daemon
      01 Puma starting in single mode...
      01
      01 * Version 3.9.1 (ruby 2.4.1-p111), codename: Private Caller
      01
      01 * Min threads: 0, max threads: 16
      01
      01 * Environment: staging
      01
      01 * Daemonizing...
      01
    ✔ 01 user@server 0.800s

Maybe something related to rbenv?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 27
  • Comments: 51 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Nice info. puma 3.10.0 works for me too!

Hi,

puma 3.10.0 works for me!

Same issue with puma 4.3.3, with capistrano3-puma 4.0.0

After deploy restart is sent, but puma is not started.

A simple solution is adding puma:start after deploy finished

namespace :deploy do 
....do something
end

after :deploy, "puma:start"

Another workaround: gem 'puma', '3.8.1'

Hey!

I have the exact same issue with puma 4. Do you have any solution?

This answer is the only “solution” I found: https://stackoverflow.com/a/44796030

But it feels wrong.

Thank you for you work!

    invoke "puma:stop"
    invoke "puma:start"

If I’m correct, this is way different from puma:restart, because it will not perform a hot restart and you may lose requests during the deploy. I do not advise to do that, please correct me if I’m wrong

Ref: https://github.com/puma/puma/blob/master/docs/restart.md#normal-vs-hot-vs-phased-restart

I have a “standard” deploy script I use in all my projects, and I have added the following line to it:

after "deploy", "puma:start"

workaround has been working fine for a couple of years now.

On Thu, 14 May 2020 at 10:13, Guillaume Briday notifications@github.com wrote:

I would like to help but I have no idea where to start, anyone could provide tips in order to submit a PR eventually ? 🙏

How people deploy in production puma with capistrano if not with this gem? I don’t understand how this issue could have been open for so long 🤔

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/seuros/capistrano-puma/issues/237#issuecomment-628700642, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2LRLZ5S3OGBOSLDBPBQ3DRRQDBXANCNFSM4DQJUEGA .

@prashantvithani Looks like 3.8.2 has the same issue (at least I didn’t notice any changes with 3.9.*), try downgrading it to 3.8.1. Worked for me

I ran into the problem that Capistrano Puma basic tasks were not showing up (restart, stop, start). This happens because, in Capistrano Puma 5.0, the tasks were moved to the service manager modules,

After

require "capistrano/puma"
install_plugin Capistrano::Puma

be sure to add:

install_plugin Capistrano::Puma::Daemon

or if you use Systemd

install_plugin Capistrano::Puma::Systemd

then all tasks should show up now and Puma should restart after deployment.

Note that Capistrano::Puma::Daemon is incompatible with Puma 5+ as daemonization support was removed. Use systemd instead (puma systemd)

Source: https://github.com/seuros/capistrano-puma/issues/310

@jmuheim it’s likely not a problem on this gem (tho I appreciate that @seuros left this issue open, as it helps getting to know that this bug still happens); it’s likely to be an issue on certain versions of Puma, maybe combined with certain versions of Bundler and / or certain versions of Rails 😕

@vast I had the same problem, I use Rails 6. I solved when I did override the task. In my config/deploy.rb I added the bellow code.

namespace :puma do
  Rake::Task[:restart].clear_actions

  desc "Overwritten puma:restart task"
  task :restart do
    puts "Overwriting puma:restart to ensure that puma is running. Effectively, we are just starting Puma."
    puts "A solution to this should be found."
    invoke "puma:stop"
    invoke "puma:start"
  end
end

I used this link as a reference https://stackoverflow.com/questions/44763777/capistrano-pumarestart-not-working-but-pumastart-does I hope that helps you