Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nor .env or environment variable PORT is used as port #17

Closed
alej0varas opened this issue Nov 29, 2012 · 8 comments
Closed

Nor .env or environment variable PORT is used as port #17

alej0varas opened this issue Nov 29, 2012 · 8 comments

Comments

@alej0varas
Copy link
Contributor

While environment variable PORT is set to 8000 or a .env file containing PORT=8000 exists, honcho still use 5000 as the port value.

@alej0varas
Copy link
Contributor Author

I'm working on this at https://github.com/alej0varas/honcho

@heyman
Copy link

heyman commented Dec 5, 2012

I have a related problem, which is that there seem to be some automatic PORT incrementing going on (https://github.com/nickstenning/honcho/blob/master/honcho/command.py#L171), which makes honcho hard to use with heroku which kills processes that listens on any other port than the one specified in $PORT. Also, it's a behavior that is different from foreman.

@nickstenning
Copy link
Owner

No, that's exactly what honcho is meant to do, and it's exactly what foreman does too:

$ honcho start -f test/fixtures/Procfile.ports -c web=3,es=1,redis=1,worker=1 | grep PORT
21:41:02 web.1    | PORT=5000
21:41:02 web.2    | PORT=5001
21:41:02 web.3    | PORT=5002
21:41:02 worker.1 | PORT=5100
21:41:02 redis.1  | PORT=5200
21:41:02 es.1     | PORT=5300
$ foreman start -f test/fixtures/Procfile.ports -m web=3,es=1,redis=1,worker=1 | grep PORT
21:41:07 web.1    | PORT=5000
21:41:07 web.2    | PORT=5001
21:41:07 web.3    | PORT=5002
21:41:07 worker.1 | PORT=5100
21:41:07 redis.1  | PORT=5200
21:41:07 es.1     | PORT=5300

The Heroku stack has a native understanding of the Procfile format, and you shouldn't need to use either honcho or foreman directly. See the Heroku documentation for further information.

Closing.

@heyman
Copy link

heyman commented Dec 6, 2012

Hi! I've now investigated this a little more, and of course found out that the port incrementing is done by both foreman as well. Sorry for the assumption that this was wrong.

However, I believe I've managed to find a difference with the $PORT between foreman and honcho. If i use -p 5000, Foreman seems to consistently set the $PORT variable for the first process of the first process type to 5000, while the process that gets assigned the 5000 port with honcho seems more random.

The following Procfile

p1: echo $PORT; sleep 1
p2: echo $PORT; sleep 1
p3: echo $PORT; sleep 1

Results in the following output with foreman:

§ foreman start -f TestProcfile -p 5000
10:08:56 p3.1      | started with pid 95661
10:08:56 p2.1      | started with pid 95660
10:08:56 p1.1      | started with pid 95659
10:08:56 p3.1      | 5200; sleep 1
10:08:56 p2.1      | 5100; sleep 1
10:08:56 p1.1      | 5000; sleep 1
10:08:56 p3.1      | process terminated
10:08:56 system    | sending SIGTERM to all processes
10:08:56 system    | sending SIGTERM to pid 95659
10:08:56 system    | sending SIGTERM to pid 95660
10:08:56 p2.1      | process terminated
10:08:56 p1.1      | process terminated

And the following with honcho:

§ honcho start -f TestProcfile -p 5000
10:09:46 p2.1   | started with pid 95670
10:09:46 p3.1   | started with pid 95671
10:09:46 p1.1   | started with pid 95672
10:09:46 p2.1   | 5000
10:09:46 p3.1   | 6001
10:09:46 p1.1   | 7002
10:09:47 p2.1   | process terminated
10:09:47 system | sending SIGTERM to all processes
10:09:47 p3.1   | process terminated
10:09:47 p1.1   | process terminated

If you're running honcho/foreman on Heroku (and I know this is unorthodox, but there are scenarios where this can be beneficial) it's good to have a deterministic way that the $PORT gets assigned.

@nickstenning
Copy link
Owner

This issue is known and has been addressed in the master branch. See issue #13.

If you have additional problems, would you mind filing separate tickets rather than using this one as a forum for discussion? Thank you!

@heyman
Copy link

heyman commented Dec 6, 2012

I believed the problem I saw was related to this issue, otherwise I wouldn't have posted here. I jumped to conclusions that was wrong, and I'm very sorry about that. I never meant to use this one as a forum, or to waste your time. Sorry =/.

@nickstenning
Copy link
Owner

No need to be sorry, and sorry if my last comment sounded curt. It was just composed on a train, that's all =).

You're not wasting my time, and not to worry about this ticket!

@eelkevdbos
Copy link

This ticket saved me another hour of debugging.

For those interested: https://ddollar.github.io/foreman/#PROCFILE

The special environment variables $PORT and $PS are available within the Procfile. $PORT is the port selected for that process. $PS is the name of the process for the line.

The $PORT value starts as the base port as specified by -p, then increments by 100 for each new process line. Multiple instances of the same process are assigned $PORT values that increment by 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants