0
votes

I would like to run two Rails servers from the same directory, on different ports. Here's what I have tried:

  1. rails s, which starts my server on port 3000.
  2. In another terminal tab, I run puma -p 7676, which starts another server on port 7676.

No matter what order I run these commands, whether I switch out puma for rails s, one of the servers always gets shut down.

The error it shows is:

A server is already running. Check /Users/<username>/<appname>/tmp/pids/server.pid.

Now, following several stack overflow answers, it seems you can tell the command where it should look for the pid:

  1. rails s
  2. rails s -p 3007 -P `pwd`/tmp/pids/alternative_server.pid

This fails with the exact same error:

A server is already running. Check /Users/<username>/<appname>/tmp/pids/server.pid.

So far my only recourse has been to clone my project in a seperate directory and run the server from there. This is obviously not ideal since I need to keep pulling any changes I make on the branch.

Versions:

  1. Puma: Version 3.6.0 (ruby 2.3.1-p112)
  2. Rails: 5.0.0.1
1

1 Answers

2
votes

You need to comment plugin :tmp_restart in config/puma.rb.

This is source code of this plugin: https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb