Skip to content

Declarative Deploys

Instead of remembering a long pam up command for every application on a server, you can describe them once in a pam.toml file and let PAM reconcile the machine to match it. pam plan shows what would change without touching anything; pam apply makes it so. The same file is safe to keep in version control: it holds names, paths and policies, while secrets stay in private environment files.

This page also covers the commands that move an application from one release to the next: pam deploy and pam rollback for local release directories, pam deploy:remote to ship to a server over SSH, and the traffic:* commands for weighted canary releases.

Create pam.toml next to your application:

pam.toml
schema_version = 1
[applications.api]
kind_code = 1
script = "index.php"
cwd = "."
workers = 4
env_file = ".env.production"
shutdown_timeout_millis = 20000
health_check_url = "http://127.0.0.1:3000/api/ping"
health_check_start_period_millis = 10000
memory_warning_bytes = 536870912
[applications.reports]
kind_code = 1
script = "index.php"
workers = 1
autostart = false

Each [applications.NAME] table becomes one managed application with that name. kind_code = 1 is a PAM runtime application (a PHP entry point started with pam start); kind_code = 2 is a Laravel application started through PAM Octane (it uses the directory’s artisan file and cannot set script).

The environment file must be private, exactly as with pam up --env-file:

Terminal window
chmod 600 .env.production
Terminal window
pam config:check
pam.toml is valid (2 applications)

config:check parses the file, checks every value against its allowed range, resolves every script and environment file, and verifies pinned extension profiles. It never starts anything.

Terminal window
pam plan
Planned 2 applications from pam.toml
api action 1
reports action 5

plan computes the action for each application without changing the machine. When you are happy with it:

Terminal window
pam apply
Applied 2 applications from pam.toml
api action 1
reports action 5

All three commands read pam.toml from the current directory by default; pass another path as the first argument. --json emits a stable document for CI:

Terminal window
pam plan --json
{"applied":false,"changeCount":2,"configurationSha256":"2a8a7157...","modeCode":1,"results":[{"actionCode":1,"name":"api","structuralIdentitySha256":"7a48ffa3..."},{"actionCode":5,"name":"reports","structuralIdentitySha256":"7a48ffa3..."}],"schemaVersion":1}

modeCode is 1 for plan and 2 for apply; changeCount counts every result that is not Unchanged.

Code Action When
1 Created The application does not exist yet; apply starts it
2 Unchanged Nothing to do
3 Scaled Only workers changed; apply runs pam scale
4 Restarted The environment file, health check or extension selection changed, or the application was stopped; apply restarts it
5 Disabled autostart = false; apply stops the application if it exists
6 PolicyUpdated Recovery, shutdown or warning thresholds changed; applied without a restart
7 ResourceLimitsUpdated memory_max_bytes or task_max_count changed; apply restarts under the new limits
8 Replaced The structural identity changed (kind_code, cwd, the resolved script, or arguments); apply replaces the application

For example, raising workers from 2 to 3 plans action 3; changing health_check_interval_millis plans action 4.

pam.toml rejects unknown keys. The top level has schema_version (must be 1) and one to 1024 [applications.NAME] tables. Application names are 1 to 64 ASCII letters, digits, ., _ or -.

Key Type Default Notes
kind_code integer required 1 PAM runtime, 2 Laravel (PAM Octane)
script path index.php Relative to cwd; not allowed for kind_code = 2
cwd path . Relative to the directory of pam.toml; must stay inside it
workers integer 1 1 to 256
arguments string array [] Passed to the application after --
autostart boolean true false keeps the application stopped
env_file path — Private (0600) KEY=value file
php_extensions string array [] Extension allowlist (up to 64); cannot be combined with a profile
php_extension_profile table — Pinned profile from pam extensions --toml (see below)
shutdown_timeout_millis integer 20000 100 to 300000
health_check_url string — http:// with an explicit loopback IP and port
health_check_interval_millis integer 5000 250 to 3600000
health_check_timeout_millis integer 1000 50 to 5000, below the interval
health_check_start_period_millis integer 0 Up to 3600000; needs a health check URL
health_check_failure_threshold integer 3 1 to 100
auto_restart boolean true Must be true when a health check is set
restart_delay_millis integer 250 10 to 60000
restart_backoff_max_millis integer 15000 At least the delay, at most 300000
max_unstable_restarts integer 10 1 to 100
min_uptime_millis integer 30000 1000 to 3600000
memory_warning_bytes integer — Raises a warning in pam monit
task_warning_count integer — Raises a warning in pam monit
memory_max_bytes integer — Hard limit through a systemd user scope
task_max_count integer — Hard limit through a systemd user scope

Every key mirrors a pam up option; see Process Management for what each policy does.

pam extensions reads your locked Composer requirements and derives the exact PHP extensions the application needs. With --toml, it prints a profile you can paste into pam.toml:

Terminal window
pam extensions --no-dev --toml
[applications.APP.php_extension_profile]
kind_code = 1
manifest_sha256 = "90da1da509c6e1c5a9f09c0d450339a6ea64ebd5739d13fbcc2a127a17873649"
lock_sha256 = "5d27910cb49eaf0e03777f51ff9404e0aa949fc3f99ffacff91f84b81099805e"
lock_content_hash = "d58bca9fd86605e6f4d5b145130151bf"
extensions = ["mbstring", "pdo_pgsql"]

Replace APP with the application name. kind_code = 1 excludes development requirements (--no-dev); 2 includes them. The profile pins the hashes of composer.json and composer.lock: when they change and the derived list no longer matches, config:check, plan and apply fail instead of silently loading a different set:

× ERROR [PAM-E005] application "api" PHP extension profile drifted at extensions; pinned ["mbstring"], derived ["mbstring", "pdo_pgsql"]

pam deploy points a managed application at a new release directory, waits for it to become ready, and records the change:

Terminal window
pam deploy api /srv/api/releases/2026-12-02
pam deploy:history api
pam rollback api
Deployed api -> /srv/api/releases/2026-12-02
RELEASE EVENT ACTIVATED_AT_MS
/srv/api/releases/2026-12-01 1 1796237109267
/srv/api/releases/2026-12-02 2 1796237109548
Rolled back api -> /srv/api/releases/2026-12-01

Event codes are 1 baseline, 2 deploy and 3 rollback. pam rollback NAME --steps N goes back N releases; history keeps the last 50 entries.

How activation works: PAM stops the current release, starts the candidate with the same settings, and waits for readiness. If the candidate fails, the previous release is restored and the command fails with release failed readiness and previous release was restored. Because the old release stops before the new one starts, expect a short gap on that port. For a reload without any gap, update the code in place (for example, a current symlink) and run pam reload NAME, or put a traffic ingress in front.

pam deploy:remote ships a Composer application to a Linux server over SSH with your system ssh and rsync, installs production dependencies there, runs bin/migrate when it exists, and activates the release through a per-application pamd:

Terminal window
pam deploy:remote [email protected] --init
pam deploy:remote [email protected] --workers 4
pam deploy:remote --dry-run

The first run with --init creates the layout, writes a private shared/.env from your .env.example when the server has none, and installs a pam-NAME.service systemd user unit that brings the application back after a reboot. On the server:

ROOT/releases/<UTC timestamp>/ one directory per release
ROOT/shared/.env linked into every release and passed as --env-file
ROOT/shared/storage/ linked as storage/
ROOT/state/ PAM_MANAGER_STATE_DIR of the application's pamd
ROOT/current -> releases/<id> the active release
Option Default Description
--init off Create shared/.env and install pam-NAME.service
--path DIR pam-apps/NAME Release root on the server (absolute, or relative to the remote home)
--name NAME pam.json name Process-manager name
--workers N — Workers of the first pam up
--health-check-url URL — Readiness URL of the first pam up
--keep N 5 Releases kept on the server
--pam PATH pam The pam executable on the server
--dry-run off Print the ssh and rsync commands only

Put the defaults in the deploy section of pam.json; command-line options win:

pam.json
{
"$schema": "https://push-in.github.io/pam-docs/schemas/pam.schema.json",
"schema": 1,
"type": 1,
"name": "acme-api",
"version": "1.0.0",
"deploy": {
"host": "[email protected]",
"path": "pam-apps/acme-api",
"workers": 4,
"healthCheckUrl": "http://127.0.0.1:3000/ready",
"keep": 5
}
}

The server needs PAM installed. deploy:remote refuses a project without composer.json.

The traffic ingress is a small Rust proxy that splits requests between a stable and a candidate address by weight, then promotes or aborts the candidate from live error rates. Weights are basis points: 10000 is 100%.

Terminal window
# Front the stable release (optionally terminating TLS)
pam traffic:start api-edge --listen 127.0.0.1:8080 --stable 127.0.0.1:8081
# Send 5% of traffic to the candidate
pam traffic:set api-edge --candidate 127.0.0.1:8082 --weight-bps 500
# Promote automatically once 1000 candidate requests have at most 0.5% errors
pam traffic:evaluate api-edge --min-candidate-requests 1000 --max-candidate-error-bps 50 --json
pam traffic:status api-edge
pam traffic:promote api-edge # or traffic:abort
pam traffic:stop api-edge

traffic:evaluate returns a decision: 1 pending (not enough candidate requests yet), 2 promoted (the candidate becomes stable), 3 aborted (error rate over the limit), 4 aborted because the rollout deadline passed. --deadline-seconds (1 to 604800, default 300) sets that deadline on traffic:start and traffic:set. traffic:start also accepts --candidate, --weight-bps, --tls-cert and --tls-key.