JANITHJAYASINGHE
ALL PROJECTS

PROJECT 06 / 10

PM2PortsCommand

PERIOD
Dec 2025 · Pull request under review
ROLE
Open-source contributor
STACK
Open source · Node.js · CLI

ARCHITECTURE OVERVIEW

01 · Input

  • pm2 ports

02 · Process list

  • Running processes
  • Cluster instances

03 · Port detection

  • 1 · Config files
  • 2 · CLI arguments
  • 3 · Environment variables

04 · Output

  • Process → port table

3

Detection priority levels

0

Breaking changes

#6069

Pull request, under review

OVERVIEW

A new pm2 ports command that shows which port every managed process is using.

A contribution to PM2, a widely used production process manager for Node.js. The new `pm2 ports` command lists running processes together with their port information, solving a common operational headache in production setups with many apps and microservices, where traditional tools fall short because of non-HTTP communication or dynamic configuration.

I designed the port detection with multi-level priority (configuration files, then CLI arguments, then environment variables), built a CLI output that matches PM2's existing design and UX, kept the change small with zero breaking changes, handled cluster mode, multiple port bindings and missing or partial configuration, and documented it in the README.

KEY CONTRIBUTIONS

  • Multi-level port detection: config files → CLI arguments → environment variables
  • CLI output aligned with PM2's existing command design
  • Zero breaking changes, minimal and maintainable footprint
  • Edge cases: cluster mode, multiple port bindings, partial configs
  • README documentation and usage examples

TECH STACK

JavaScriptNode.jsCLI / terminal UIOpen-source workflow

NEXT PROJECT · 07 / 10

Provincial Environmental Authority System

KEEP SCROLLING OR CLICK