Do you have multiple Rails apps running on your machine? Tired of conflicts on port 3000? I was, so I vibe-coded this gem.
Port of Call automatically assigns deterministic port numbers to each Rails application based on its name.
Rails developers who tend to work on multiple applications simultaneously
Port of Call deterministically assigns port numbers to Rails applications:
- It extracts your application's name from Git or directory name
- It creates a hash of the name using SHA256
- It maps this hash to a port number within your configured range (default: 3000-3999)
- It automatically sets this port when you start your Rails server
The same app always gets the same port on any machine, avoiding conflicts!
-
Install the gem:
# In your Gemfile gem 'port_of_call'
-
Bundle install:
$ bundle install
-
Generate the initializer (optional):
$ rails generate port_of_call:install
-
Run your server as usual:
$ rails server
CLI Commands:
port_of_call server- Start Rails server with calculated portport_of_call port- Show the calculated portport_of_call set- Set as default port in development.rbport_of_call -v- Show version informationport_of_call -h- Show help
Rake Tasks:
rake port_of_call- Show calculated portrake port_of_call:start- Start Rails serverrake poc- Shorthand for starting the server
- After checking out the repo,
- run
bin/setupto install dependencies. - Then, run
rake specto run the tests. - You can also run
bin/consolefor an interactive prompt.
# In config/initializers/port_of_call.rb
PortOfCall.configure do |config|
# Change port range (default: 3000..3999)
config.port_range = 4000..4999
# Set custom project name
config.project_name = "my_unique_app_name"
# Avoid specific ports
config.reserved_ports = [4567, 5000]
end- If your port is already in use, Port of Call will warn you
- To check port availability:
rake port_of_call:check - For detailed info:
rake port_of_call:info