A recent commit changed the “unicorn port” from 9292 to 3000 in Discourse development, causing conflicts with other Rails sites. typeoneerror initially tried to change the port using different methods, but was unsuccessful. However, changing the port in bin/rails to 3001 worked.
sam suggested two approaches to launching a rails server in development: either using bin/unicorn for a pristine console, or bin/rails s to see all debug Rails logs. To change the port, one can use bin/unicorn -p <port> or bin/rails s -p <port>.
Additionally, pmusaraj introduced an option to reduce log noise when using rails s, allowing users to see puts statements locally without the noise by setting DISCOURSE_DEV_LOG_LEVEL="warn".
A recent commit changed the “unicorn port” from 9292 to 3000. I don’t see any way to change the port now and this is confliciting with another rails site I have running on 3000. Previously, I’ve been running discourse as bundle exec rails server --port=3001, but this no longer works as unicorn is now grabbing 3000.
Tried a few combinations of UNICORN_PORT=3001, --port=3001, changing source code of unicorn.conf, but end up with:
I, [2018-08-14T11:26:11.496753 #63852] INFO – : listening on addr=0.0.0.0:3000 fd=20
Donno, Matt. I followed Install Discourse on macOS for development which didn’t have me setting up containers (I’m assuming you’re referring to Docker or something related?).
There are 2 schools of thought when it comes to launching a rails server in development.
The @sam school of thought, where you want to keep console pristine cause you are a fanatical puts debugger. That way you can just add puts statements around the app and see the output in the same window you run the server.
If you subscribe to @sam’s school of thought you launch your rails server with:
bin/unicorn
If you want a different port, you run
bin/unicorn -p 7777
The other school of thought is the @tgxworld school of thought / Rails official setup. In this case are not a puts debugger and want to see all the debug rails logs in the console.
If you are like this you would launch unicorn in dev via
bin/rails s
If you want a custom port you will use
bin/rails s -p 7777
Note, I had to push a few fixes to make this post true, so pull latest.
Or you subscribe to @LeoMcA’s school of thought, where you’re a fanatical puts debugger, but launch with rails s, so you have to squint really hard to see what you want among all the rails logs.
Yeah, I launch my local dev with Puma via Foreman so I think I get “puts” in the Foreman logs and “logger.log” in the Rails log, so I think I’m with the @sam school in my other project. Nice to have these two schools for Discourse local dev now!