Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hang on SIGTERM with ruby 2.6 in clustered mode #1755

Closed
vbalazs opened this issue Mar 27, 2019 · 5 comments
Closed

Hang on SIGTERM with ruby 2.6 in clustered mode #1755

vbalazs opened this issue Mar 27, 2019 · 5 comments
Labels

Comments

@vbalazs
Copy link

vbalazs commented Mar 27, 2019

Steps to reproduce

  1. Create a config.rb file with this content and run mkdir -p tmp/pids
# frozen_string_literal: true

app_dir = File.expand_path(__dir__)

workers 4
threads 1, 8

bind "tcp://0.0.0.0:#{ENV.fetch('PORT', 3000)}"

pidfile "#{app_dir}/tmp/pids/puma.pid"
state_path "#{app_dir}/tmp/pids/puma.state"

app do |env|
  puts env
  body = 'Hello, World!'

  [200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
end
  1. puma -C config.rb
  2. Send a TERM signal to the cluster process
$ /bin/kill -TERM `cat tmp/pids/puma.pid`

Expected behavior

Gracefully shuts down workers

Actual behavior

Process hangs, requires KILL

System configuration

Ruby version: 2.6.2
Puma version: 3.12.1
Platform: Ubuntu 18.04 (4.15.0-1032-aws)

Additional info

It works with Ruby 2.5.5.

I discovered this using puma with systemd, it times out and kills the process after a certain time. I checked the signals docs, with INT is really working but from the documentation is not clear if I can just use this signal instead without any other side effect.

if in systemd service descriptor I set ExecStop=/bin/kill -INT $MAINPID , it seems to work but it throws this error like it tries to stop the server twice:

api-puma[28423]: [28423] - Gracefully shutting down workers...
api-puma[28423]: [28423] - Gracefully shutting down workers...
api-puma[28423]: /opt/myapp/shared/vendor/ruby/2.6.0/gems/puma-3.12.1/lib/puma/cluster.rb:40:in `waitpid': No child processes (Errno::ECHILD)
@calmyournerves
Copy link

This is probably the same issue described in #1674 and #1730.

@Aesthetikx
Copy link

As additional anecdotal evidence, with puma 3.12.0 and ruby 2.6.2 in clustered mode on heroku, a SignalException: SIGTERM will be raised a few minutes after every deploy, which does not happen on 2.5.3.

@dentarg
Copy link
Member

dentarg commented Apr 2, 2019

Yep, I can confirm what @Aesthetikx says. #1674 (comment)

@Aesthetikx
Copy link

Another anecdote, b94c3e3 (not yet released) fixes the issues we experienced on heroku.

@dentarg
Copy link
Member

dentarg commented Jul 26, 2019

@nateberkopec this one can be closed as the workaround (#1741) has been released with Puma 4.0.0

dentarg added a commit to dentarg/puma that referenced this issue Aug 24, 2019
dentarg added a commit to dentarg/puma that referenced this issue Aug 24, 2019
nateberkopec pushed a commit that referenced this issue Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants