Reputation: 6222
I have a Ruby web API and using Rack, the config.ru
file looks like this:
#\ -p 8080 -o 0
run App::API
It works well, but if I want to change port for web server using rackup
arguments it won't work. It seems the first line parameters in config.ru
override the command line arguments. I couldn't find anything on Rack documentation that explains this behaviour.
The question is if I execute Rack server like this:
bundle exec rackup -p 8000
I expect it to bind to port 8000
but it still binds to port 8080
. How can I change the port without changing the config.ru
file?
Upvotes: 2
Views: 1900
Reputation: 6222
So I decided to submit a pull request for Rack to fix this weird behaviour. Reading the code I realized something very strange, the code should work as I expected :|
It favours command line arguments over config file (config.ru
)!
Digging into code commits reveals that this changes are not merged into any stable version yet (1.6.4
). It's actually in version 2.0.0.alpha. Which is obviously not production ready.
Here is the commit: https://github.com/rack/rack/commit/d924f8074e0b3d6c49881c33f983ef323258a941#diff-b578c27b65b1d4a848181b8c1ca082fdL300
So the answer is: it's not possible in 1.x versions and I should either change config.ru
or forget about that :(
Upvotes: 3