Why is foreman gem ignoring the PORT environment variable?

前端 未结 2 1454
旧时难觅i
旧时难觅i 2021-02-08 03:22

I want the foreman gem to use the PORT value provided in the my development env file instead of using its own values. My files setup is shown below:

  1. A bash scri

2条回答
  •  太阳男子
    2021-02-08 03:33

    I know this is an old post but it took me a while to figure out so might as well add a note here.

    Foreman increments the PORT based on where your define the service in the Procfile.

    Say our PORT environment variable is set to 3000.

    In our first Procfile example Puma will run on PORT 3000:

    web: bundle exec puma -q -p $PORT
    worker: bundle exec rake jobs:work
    

    But in our second Procfile it will run on PORT 3100 as the PORT variable is used on the second line.

    worker: bundle exec rake jobs:work
    web: bundle exec puma -q -p $PORT
    

    Not sure why, I guess to prevent different processes from trying to take the same PORT.

提交回复
热议问题