Search code examples
ruby-on-railsherokuprocfile

What does ${PORT:-3000} mean in Heroku Procfile?


Heroku suggests this Procfile command to start Puma on Rails 5 setup:

web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}

At first I thought 3000 was a default value, but in fact foreman uses port 5000 if PORT is missing in development.

Question: What does the notation ${VARIABLE:-3000} mean?

--

Update: It seems like puma is the culprit: Foreman/Puma isn't using the specified port in dev env


Solution

  • That is the default value of the VARIABLE.

    Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

    From: https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion

    In this case if the PORT variable is not set then its value will be 3000 and similarly if RACK_ENV is not set then it will be development.