1

I just updated from MacOS 12.x to 13.0.1

Starting a Rails app with

➜ rails s

works fine

=> Booting Puma
=> Rails 5.2.8.1 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.6 (ruby 2.6.6-p146), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop

But when I try with

➜ rails s -d

Output stops at

=> Booting Puma
=> Rails 5.2.8.1 application starting in development
=> Run `rails server -h` for more startup options

And no server is started

➜ ps -ef | grep puma
501 69877 51917   0  6:45   ttys000    0:00.00 grep puma

➜ ps -ef | grep rails
501 72493 51917   0  6:49   ttys000    0:00.00 grep rails

2 Answers2

0

Well, I found a workaround. This is by no means perfect but if it helps anyone with the same problem:

nohup rails s </dev/null >/dev/null 2>&1 &

The & at the end will make it run in the background. All output/input goes to/from /dev/null and nohup makes sure it will run even after you quit the session.

  • 1
    An easier workaround is `nohup rails server --no-log-to-stdout >/dev/null &`, which does pretty much the same: `rails server --no-log-to-stdout &` put the server in background and stops the output (you don't have to mess with file descriptors), and `nohup >/dev/null` gets rid of the nohup.log file. – Claudio Floreani Feb 02 '23 at 13:10
0

The reason has nothing to do with the fact that you updated to MacOS Ventura.

Puma daemonization has been removed without replacement since version 5.0.0, and it has been extracted to the puma-daemon gem, which currently works only with Puma version ~> 5.

Therefore now you have two ways to make it work: with puma-daemon, or put it in no hanghup background mode.


METHOD 1: USING PUMA DAEMON GEM

  1. bundle add puma-daemon
  2. Add these line to your application’s Gemfile: gem 'puma-daemon', require: false gem 'puma', '~> 5'
  3. Add these lines to config/puma.rb: require 'puma/daemon' daemonize and ensure you have set up at least one worker (workers 1)

Now you should be able to run puma webserver as a daemon with rails server (please notice that you must remove any -d or --daemonize from the command line)


PUT IT IN NO HANGHUP BACKGROUND MODE

Just run rails server --no-log-to-stdout & to put the server in background and stop the output, and enclose it in a nohup >/dev/null command to get rid of the nohup.log file:

nohup rails server --no-log-to-stdout >/dev/null &

This method works with any Puma version and doesn't require the gem.


Don't mess around with the two ways.

Claudio Floreani
  • 2,441
  • 28
  • 34