π§ Port Kill
A lightweight macOS status bar app that monitors and manages development processes running on ports 2000-6000. The app provides real-time process detection and allows you to kill individual processes or all processes at once.
Features
Real-time Monitoring : Scans ports 2000-6000 every 5 seconds using lsof commands
: Scans ports 2000-6000 every 5 seconds using commands Visual Status Bar Icon : Shows process count with color-coded center (green=0, red=1-9, orange=10+)
: Shows process count with color-coded center (green=0, red=1-9, orange=10+) Dynamic Context Menu : Updates every 3 seconds with current processes and kill options
: Updates every 3 seconds with current processes and kill options One-Click Process Killing : Click any menu item to kill all detected processes
: Click any menu item to kill all detected processes Safe Process Termination : Uses SIGTERM β SIGKILL termination strategy
: Uses SIGTERM β SIGKILL termination strategy Stable Architecture : Built with winit event loop for macOS compatibility
: Built with winit event loop for macOS compatibility Graceful Error Handling : Handles permission errors and process failures
: Handles permission errors and process failures No Windows: Pure status bar application with no main window
Status Bar Icon
The status bar icon provides instant visual feedback:
Green : 0 processes (safe, no development servers)
: 0 processes (safe, no development servers) Red : 1-9 processes (some development servers)
: 1-9 processes (some development servers) Orange: 10+ processes (many development servers)
Hover over the icon to see the exact process count in the tooltip.
Menu Options
Kill All Processes : Terminates all detected development processes
: Terminates all detected development processes Individual Process Entries : Format: "Kill: Port 3001: node (PID 1234)"
: Format: "Kill: Port 3001: node (PID 1234)" Quit: Exits the application
Note: Currently, clicking any menu item will kill all processes (for testing purposes).
Requirements
macOS 10.15 or later
Rust 1.70 or later
lsof command (included with macOS)
Installation
Clone the repository:
git clone < repository-url > cd port-kill
Build the application:
cargo build --release
Run the application (easy way):
./run.sh
Run manually (alternative):
cargo run --release
Usage
Start the Application: Run ./run.sh to start the application Monitor Status: Check the status bar for the process count indicator Access Menu: Click on the status bar icon to open the context menu Kill Processes: Click "Kill All Processes" to terminate all development processes
Click individual process entries to kill specific processes Quit: Click "Quit" to exit the application
Technical Details
Architecture
Main Thread : Handles UI events and menu interactions with winit event loop
: Handles UI events and menu interactions with winit event loop Process Monitor : Scans for processes every 5 seconds using lsof
: Scans for processes every 5 seconds using Menu Updates : Updates context menu every 3 seconds when processes change
: Updates context menu every 3 seconds when processes change Process Killing: Runs in background threads to maintain UI responsiveness
Process Detection
The application uses the following command to detect processes:
lsof -ti :PORT -sTCP:LISTEN
Process Termination
SIGTERM: First attempts graceful termination SIGKILL: If process doesn't terminate within 500ms, forces termination
Port Range
Monitors ports 2000-6000 (broad range covering common development server ports)
Dependencies
tray-icon : macOS status bar integration
: macOS status bar integration winit : Event loop management
: Event loop management nix : Signal handling for process termination
: Signal handling for process termination crossbeam-channel : Thread communication
: Thread communication tokio : Async runtime
: Async runtime anyhow : Error handling
: Error handling serde : Data serialization
Development
Building for Development
cargo build
Running with Logging
RUST_LOG=info cargo run
Troubleshooting
Permission Issues
If you encounter permission errors when trying to kill processes:
Ensure the application has the necessary permissions Some system processes may be protected Check if the process is owned by another user
Process Not Detected
If a process is not being detected:
Verify the process is listening on a port in the 2000-6000 range Check if the process is using TCP (not UDP) Ensure the process is in LISTEN state
Application Not Starting
If the application fails to start:
Check if another instance is already running Verify all dependencies are installed Check system logs for error messages
License
This project is licensed under the FSL-1.1-MIT License. See the LICENSE file for details.
Contributing