Project

locport

0.0
No release in over 3 years
Overview of localhost ports used across projects. Prevent conflicts.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.10
~> 5.0
~> 13.0

Runtime

~> 1.3
 Project Readme

locport

locport-logo
  • Standardizes keeping track of local development ports.
  • See which ports are listening.
  • Automatically assign unused ports.
  • See conflicts.
  • Proxy and daemon free.

Introducing the .localhost file convention

A project can define within it's root, the .localhost file, that lists local hosts with ports that the project uses.

Format of this file is a simple list of <host>:<port> separated by newlines. For example:

hello.localhost:3001
another.service.localhost:3002

A single project can have multiple addresses associated to it.

To add the project to locport, simply locport index [PATH1] [PATH2]. Now you can overview hosts and ports with locport and easily discover conflicts across any number of projects.

You can also add projects recursively, like so: locport index ~/projects -r. This will look for directories that contain .localhost file and indexes those.

Installation

Ruby is required.

gem install locport

Usage

Adding hosts

You've got several options to create or add to .localhost file, from within your project directory:

# Creates .localhost file in the current directory, with randomly assigned unused port,
# and hostname based on the current directory name suffixed with .localhost
locport add

# Adding a custom hostname and letting locport find a port
locport add myapp.localhost

# Example with a user specified port
locport add myapp.localhost:30000

All of the above action ensure the project is also indexed by locport.

Listing projects and hosts

locport
# OR
locport list

If any conflicts are detected, they will be displayed and program exits with error code 1.

Adding existing projects to the index

# Add specific projects that contain .localhost file
locport index ~/projects/a ~/projects/b

# Recursively find and index .localhost files
locport index -r ~/projects

You can view the location of the projects index, which is a single text file, containing project paths, separated by a newline.

locport info

Screenshots

adding and listing conflicts

Development

PRs are welcome. To set up locally from within the checked out repo:

# Install dependencies
bundle

# Run commands with dev code
ruby -Ilib/ bin/locport

Running tests

bin/rake