Why will the Puma server not pickup changes to the code?

1.1k Views Asked by At

I am running a local puma server for my rails app.

This is in my local_env.yml file

STAGING_URL: 'http://statrubytwotwo.test'

I can hit the URl when the server is running and all works fine. If I shut the server down with Cntrl-C and then hit the server it is still running.

To get the server to shutdown I have to do

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

The main problem is I change code. Do a git add * --all and a git commit -m "something here" and then start the server via bundle exec puma

The server starts up again, but the code changes are NOT seen. The puma server is running the old code?

UPDATE ====

I killed all with the following:

puma-dev -stop
pkill -9 -f 'rb-fsevent|rails|spring|puma'
pkill -USR1 puma-dev

I did a rails s and I see this

Puma starting in single mode...
* Version 3.11.4 (ruby 2.3.1-p112), codename: Love Song
* Min threads: 0, max threads: 16
* Environment: staging
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

I hit the https://stattwotwo.test domain and it loads.

I hit http://localhost:3000 and NOT FOUND

I hit the https://stattwotwo.test domain and it loads

No matter what I do nothing ever loads on http://localhost:3000

I believe I recall the puma-dev will start anytime the domain is hit even if it is down (forman or pow)? Either way when it restarts it is not using new code.

1

There are 1 best solutions below

2
On

Adding as a response because I can't fit it all in a comment:

You need to find out which tool you're using. My guess would be puma-dev, and you installed it as a background process via here

See if you can confirm.

Normally you'd get a conflict if there were 2 servers running, but that runs on a port other than the puma/rails default of 3000, which is what default bundle exec puma runs (I think?)

If that's the case, you've been starting a new server on a different port, while the old server (running your old cached code from when it started) is still running. That's why you don't see the changes.

You can confirm a couple things:

  • Don't do bundle exec puma, do rails s and check the log to the screen and see if :3000 is there
  • Kill your puma like you've been, but visit your URL and see if it's still running
  • Start rails s again, and visit http://localhost:3000 and see if your code changes when you reload pages as you expect.
  • Do puma-dev -stop, then rails s, and visit your .test url and see if it breaks (that means puma-dev was running in the background)