pm3 logopm3
Guides

CI/CD

Use pm3 in CI/CD pipelines with JSON output and health check gating.

pm3's --json flag and health checks make it useful for CI/CD pipelines — starting services, waiting for readiness, running tests, and shutting down.

JSON Output

Add --json to any command for machine-readable output:

pm3 list --json
{
  "type": "process_list",
  "processes": [
    {
      "name": "api",
      "pid": 42150,
      "status": "online",
      "uptime": 130,
      "restarts": 0
    }
  ]
}
pm3 info api --json

Waiting for Readiness

Use --wait to block until all processes are online before continuing:

pm3 start --wait

This is especially useful with health checks — --wait blocks until every health check passes (60s timeout):

pm3.toml
[api]
command = "node server.js"
health_check = "http://localhost:8080/health"

[database]
command = "docker start -a postgres-test"
health_check = "tcp://localhost:5432"
pm3 start --wait && npm test

Example CI Pipeline

.github/workflows/test.yml
- name: Install pm3
  run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/frectonz/pm3/releases/download/0.1.5/pm3-installer.sh | sh

- name: Start services
  run: pm3 start --wait

- name: Run tests
  run: npm test

- name: Cleanup
  if: always()
  run: pm3 kill

Scripting Tips

Check if a specific process is online

STATUS=$(pm3 info api --json | jq -r '.info.status')
if [ "$STATUS" = "online" ]; then
  echo "API is ready"
fi

Get process PID

PID=$(pm3 info api --json | jq -r '.info.pid')

Count running processes

ONLINE=$(pm3 list --json | jq '[.processes[] | select(.status == "online")] | length')
echo "$ONLINE processes online"

Fail if any process errored

ERRORED=$(pm3 list --json | jq '[.processes[] | select(.status == "errored")] | length')
if [ "$ERRORED" -gt 0 ]; then
  echo "Some processes have errors"
  pm3 list
  exit 1
fi

On this page