I am using foreman
to start a bunch of services, and have the following line in the Procfile.
web: bundle exec rails server -p ${PORT:-3000}
yet when the server starts it starts on the default Foreman port of 5000
, so it looks like the syntax for injecting 3000
as the default port is wrong.
I went looking (someone else gave me the line above so I'd like to fix it) and could not actually find any specific documentation on how to inject a default value.
Looking at the source you see
def expanded_command(custom_env={})
env = @options[:env].merge(custom_env)
expanded_command = command.dup
env.each do |key, val|
expanded_command.gsub!("$#{key}", val)
end
expanded_command
end
so it's clear that the ${PORT:-3000}
syntax is wrong.
What is the correct way to set a default port?