Reserve and manage localhost ports; atomically update .env and config.json
Project description
PortKeeper
Reserve and manage localhost hosts/ports for starting servers. Transparently updates .env and config.json files and keeps a local registry so multiple processes and users can coordinate port reservations.
Features
- Reserve a free port (optionally with preferred port or a search range)
- Optionally hold the port by binding a dummy socket (prevents others from taking it)
- Release reservation
- Atomic updates to
.envandconfig.json(with backup) - Simple file locking to avoid races
- Context manager API and a tiny CLI (
portkeeper)
Quickstart
pip install portkeeper
# Reserve preferred 8888 or a port in 8888-8988, hold it, and print JSON
portkeeper reserve --preferred 8888 --range 8888 8988 --hold --owner myapp
# From Python
from portkeeper import PortRegistry
with PortRegistry().reserve(preferred=8888, port_range=(8888, 8988), hold=True) as r:
PortRegistry().write_env({'PORT': str(r.port)})
CLI
reserve [--preferred P] [--range START END] [--hold] [--owner OWNER] [--write-env KEY]release PORTstatus(list reserved ports in registry)gc(garbage-collect stale registry entries)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
portkeeper-0.1.0.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file portkeeper-0.1.0.tar.gz.
File metadata
- Download URL: portkeeper-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21032c9c2ce933985c36efc87c25cd71997050b11db6bbd3adf32149329ffa7d
|
|
| MD5 |
d4bdd689be6ee97e22142fa981cad210
|
|
| BLAKE2b-256 |
d11048a98b3fa218bf13850d7192b830779a228611b5790bc377c58e9fa2eb6b
|
File details
Details for the file portkeeper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: portkeeper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dc715f0e3d76d458adec59bf6b327f73f2f5ee6713e3bbef291248248b15af4
|
|
| MD5 |
d13682b40dd96be27e45de9316e957f2
|
|
| BLAKE2b-256 |
308bda0a9f8b2f8c72b466e50b49b2b1b5d1534ece247ed3e3e133e32e3fffad
|