Process Management
pam start runs a cluster in the foreground. When you want the application to keep running after your terminal closes, restart on crashes, rotate its logs, answer health checks and come back after a reboot, use the PAM process manager. It is built into the pam binary: think of it as a small, PHP-aware PM2.
pam up --name api --workers 4pam pspam logs api --followpam reload apipam stop apiBehind these commands runs pamd, a per-user supervisor daemon that the CLI starts on demand. Every managed application is still a normal pam start master with its own workers, so everything on Clustering applies.
Starting an Application
Section titled “Starting an Application”Run pam up from the application directory:
pam up --name api --workers 4 --health-check-url http://127.0.0.1:3000/readyStarted api (PID 1024714, 4 workers)- The target defaults to
index.php. In a Laravel project (a directory with anartisanfile) and without an explicit target, PAM starts PAM Octane instead. - The name defaults to the directory name. Names must be unique;
pam uprefuses a name that already exists, online or stopped. - Arguments after
--belong to your application. --attachkeeps the application in the foreground with your terminal’s standard streams.
Options
Section titled “Options”| Option | Default | Description |
|---|---|---|
--name NAME |
directory name | Managed application name |
--workers N |
available CPUs | Passed to pam start |
--max-requests N |
— | Passed to pam start |
--task-workers N|auto |
— | Passed to pam start |
--php-extension NAME |
— | Repeatable extension allowlist (isolated mode) |
--isolate-php-extensions |
off | Isolate extensions even with an empty allowlist |
--env-file PATH |
— | Load environment variables from a private file (see below) |
--attach |
off | Stay in the foreground |
--json |
off | Machine-readable result |
--shutdown-timeout-ms N |
20000 | Graceful stop deadline (100 to 300000) before a forced stop |
--health-check-url URL |
— | http:// loopback URL probed by the daemon |
--health-check-interval-ms N |
5000 | Probe interval (250 to 3600000) |
--health-check-timeout-ms N |
1000 | Probe timeout (50 to 5000, below the interval) |
--health-check-start-period-ms N |
0 | Grace period after start (up to 3600000) |
--health-check-failures N |
3 | Consecutive failures before a restart (1 to 100) |
--no-autorestart |
autorestart on | Do not restart after an unexpected exit |
--restart-delay-ms N |
250 | First restart delay (10 to 60000) |
--restart-backoff-max-ms N |
15000 | Backoff ceiling (up to 300000) |
--max-unstable-restarts N |
10 | Unstable restarts before the circuit opens (1 to 100) |
--min-uptime-ms N |
30000 | Uptime that counts as stable (1000 to 3600000) |
--log-max-bytes N |
10485760 | Rotate a log file at this size |
--log-retain N |
5 | Rotated files to keep (up to 100) |
--memory-warning-bytes N |
— | RSS that raises a warning in monit |
--task-warning-count N |
— | Task (thread) count that raises a warning |
--memory-max-bytes N |
— | Hard memory limit through a systemd user scope (MemoryMax) |
--task-max-count N |
— | Hard task limit through a systemd user scope (TasksMax) |
Environment Files
Section titled “Environment Files”--env-file loads KEY=value lines into the application’s environment. Because the file usually holds secrets, PAM only accepts a file owned by you with mode 0600 or stricter (at most 64 KiB and 256 variables):
chmod 600 .env.productionpam up --name api --env-file .env.productionOtherwise pam up fails with environment file must be owned by the current user and mode 0600 or stricter.
Listing and Inspecting
Section titled “Listing and Inspecting”pam psNAME STATUS PID WORKERS DIRECTORYapi online 1024714 2 /srv/apipam status NAME prints a one-line state (api is online); pam describe NAME prints the full JSON record: desired state, PIDs, worker startup timings, health-check counters, recovery state, resource policy and the paths of both log files. Add --json to ps, status and most other commands for automation.
Each application writes standard output to NAME.out.log and standard error to NAME.error.log, rotated by size.
pam logs api # last 100 lines of stdoutpam logs api --errors --lines 200pam logs api --both --followpam logs api --query timeout --include-rotated --json| Option | Description |
|---|---|
--lines N |
How many lines to show (default 100; structured queries cap at 10000) |
--errors |
Read standard error instead of standard output |
--both |
Read both streams |
--follow, -f |
Keep streaming new lines |
--query TEXT |
Only lines containing TEXT (1 to 256 characters) |
--include-rotated |
Also search rotated files |
--json |
Emit structured entries |
--follow cannot be combined with --json, --query or --include-rotated, and --errors cannot be combined with --both.
Reloading, Restarting and Scaling
Section titled “Reloading, Restarting and Scaling”pam reload api # zero-downtime reload (SIGHUP to the master)pam restart api # stop, then start againpam scale api 12 # change the worker count (1 to 256) and restartpam stop api # graceful stoppam delete api # forget a stopped applicationUse reload to deploy new code in place: the master boots a new generation and drains the old one only after it is ready. restart and scale restart the master. stop waits up to the application’s shutdown timeout, then forces the stop.
Automatic Recovery
Section titled “Automatic Recovery”When a managed master exits unexpectedly, pamd restarts it. The delay starts at --restart-delay-ms, doubles after each unstable restart up to --restart-backoff-max-ms, and resets once the application has been up for --min-uptime-ms. After --max-unstable-restarts, PAM opens a circuit and waits for an explicit pam restart NAME.
With --health-check-url, pamd also probes the application over HTTP and restarts it after --health-check-failures consecutive failures. The URL must be http:// with an explicit loopback IP and port. Health checks require autorestart.
On Linux, pamd watches each master through a pidfd, so it notices a crash immediately instead of polling.
Resource Monitoring
Section titled “Resource Monitoring”pam monitPAM MONITNAME STATE PID WORKERS RSS_BYTES TASKS ALERTapi online 1024714 2 112717824 10 1RSS and tasks cover the whole process tree of the application. The ALERT code is 1 healthy, 2 memory warning, 3 task warning, 4 both, 5 unavailable.
pamd samples every application once a minute and keeps the last 120 samples:
pam monit:history api --limit 30pam monit:history --jsonpam monit:history --record # take a sample now before printingHard Limits
Section titled “Hard Limits”--memory-max-bytes and --task-max-count launch the application inside a transient systemd user scope with MemoryMax and TasksMax, so the kernel enforces them. They require /usr/bin/systemd-run. describe reports whether the cgroup limit was verified (enforcementCode 1 enforced, 2 not requested, 3 unverified).
Dashboards
Section titled “Dashboards”Write a private, self-contained HTML health page of every managed application:
pam dashboard pam-dashboard.htmlThe file is created with mode 0600. For a live view, start the authenticated local dashboard. It requires a loopback address and an owner-only token file:
umask 077openssl rand -hex 32 > ~/.config/pam-dashboard.tokenpam dashboard:start --listen 127.0.0.1:9615 --token-file ~/.config/pam-dashboard.tokenpam dashboard:statuspam dashboard:stop127.0.0.1:9615 is the default listen address.
The pamd Daemon
Section titled “The pamd Daemon”The CLI starts pamd automatically. You can also manage it directly:
pam daemon startpam daemon status # "pamd is online (PID ...)", exit code 1 when stoppedpam daemon stopSurviving Reboots
Section titled “Surviving Reboots”Save the list of running applications and install a systemd user service that restores it:
pam savepam startup --print # inspect the unit firstpam startup --installsystemctl --user enable --now pamd.servicepam startup --install writes ~/.config/systemd/user/pamd.service. To restore the saved list by hand, run pam resurrect. For the service to run without an open login session, enable lingering for the user (loginctl enable-linger <user>).
State Location
Section titled “State Location”| What | Where |
|---|---|
| Records, logs, history | $PAM_MANAGER_STATE_DIR, else $XDG_STATE_HOME/pam, else ~/.local/state/pam |
| Daemon socket | $PAM_MANAGER_RUNTIME_DIR, else $XDG_RUNTIME_DIR/pam, else the state directory |
To run a fully separate manager (handy for CI, or for several isolated sets of applications on one host), set both variables. With only PAM_MANAGER_STATE_DIR, the CLI still talks to the daemon listening on the default socket. pam deploy:remote sets both to give each application its own pamd:
export PAM_MANAGER_STATE_DIR=/srv/acme/stateexport PAM_MANAGER_RUNTIME_DIR=/srv/acme/state/runpam up --name apiNext Steps
Section titled “Next Steps”- Declarative Deploys:
pam.toml,pam deploy, rollbacks and canaries. - Clustering: what runs inside each managed application.
- CLI Reference for every flag.