Change unicorn port from 3000 in development

(Benjamin Borowski) #1

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= fd=20

Each time.

Any way to work around this?

(Benjamin Borowski) #2

Changed that line in bin/rails to point to 3001 and it seems to work now. Should that line be an ||=?

(Matt Palmer) #3

Why do you have another Rails site running in the same container as Discourse?

(Benjamin Borowski) #4

Donno, Matt. I followed Beginners Guide to 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?).

(Sam Saffron) #5

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:


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.

(Benjamin Borowski) #6

You rock, @sam, cheers!

(Leo McArdle) #7

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.

I feel like a fool.

(Benjamin Borowski) #8

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!