puma: Puma won't die when killing rails server with ctrl-c

Steps to reproduce

  1. run a tiny rails server, with puma configured in the Procfile web: bundle exec puma -C config/puma.rb

  2. start the rails server

  3. kill the server in the terminal with ctrl-c

Expected behavior

The server should shut down

Actual behavior

Puma hangs with Gracefully shutting down workers.... It’s undead, can’t be killed with another ctrl-c nor a ctrl-d. Even manually finding the processes by pid and killing them won’t unfreeze the server. Somehow puma can’t even be killed with pkill -f puma

System configuration

Ruby version: Ruby ruby 2.3.3

Rails version: Rails 5.0.1

About this issue

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

Commits related to this issue

Most upvoted comments

Cannot reproduce. 99% certain this is an issue on your end, rather than Puma. What happens if you send SIGKILL? pkill -9 -f puma

I’ve found sending SIGQUIT (via Ctrl-\) will kill the process.

Ah, I didn’t know you can pass -9 to pkill. That finally gets rid of it.

Also, lots of rb-fsevent processes stay open too. I kill everything with:

pkill -9 -f 'rb-fsevent|rails|spring|puma'

Output when it’s stuck in shutdown mode:

$ ps aux | grep puma
         3053  98.8  1.0  2757276 161812 s000  R+    9:24PM   0:17.78 puma: cluster worker 1: 3027 [rails-app]
         3027   0.0  0.5  2560964  77584 s000  S+    9:24PM   0:02.46 puma 3.7.0 (tcp://0.0.0.0:3000) [rails-app]
         3363   0.0  0.0  2451236   2064 s006  S+    9:30PM   0:00.00 grep puma

Not sure if there’s a sure-fire way to solve this or if the solution is simply to send SIGQUIT (via Ctrl-\), but I’m still having this issue as well.

Does anyone know why these workers stop synching, specifically in the case that was mentioned 8 comments up on this gist, where you have set “Web_concurrrency” to { 2 }?

Can confirm SIGQUIT worked for me.

I believe this is the same issue as https://github.com/puma/puma/issues/1046. I’m still experiencing this with Rails 5.1 and Puma 3.10.0.

Edit: Hmm no, I think this is different. On previous versions of Puma/Rails I could specify workers 1 in my puma config and as long as I started it with rails server -b 127.0.0.1 I could restart using rails restart. This is no longer the case. If I simply specify that I want to use a worker it fails to restart, hanging on “Gracefully shutting down workers…”. Setting workers 0 seems to fix it though.