DevOps

2026 OpenClaw macOS: 스테이징 vs 프로덕션 워크스페이스, 포트 & LaunchAgent 분리

xxxMac 기술팀
약 15분

Teams renting a single Mac mini M4 for both production automations and risky OpenClaw experiments collide when two gateways read the same config tree, bind duplicate ports, or recycle one gateway.auth.token—the failure mode looks like flaky networking even though launchd insists both jobs are healthy. This 2026 playbook shows how to isolate staging and production with distinct directories, listener ports (default 18789 vs staging 18790), LaunchAgent labels, environment files, and log sinks so you can rehearse channel changes without taking revenue workflows offline. Expect a layout contract table, a six-step bootstrap checklist, permission guidance, and FAQ entries sized for on-call handoffs.

Shared Web VNC sessions are a secret sprawl risk: If anyone pastes tokens into a browser on the same host, assume both environments are burned. Rotate staging and production tokens independently, reload each LaunchAgent within 5 minutes, and audit plist file modes (0640) plus parent directories at 0750.

Read alongside the gateway troubleshooting guide for token and restart loops, the launchd persistence guide for ThrottleInterval and KeepAlive nuances, and secrets management on M4 for key storage patterns. When disk pressure from doubled log volume appears, apply the SSD retention matrix before you blame CPU or RAM.

Why a single HOME-based config collapses under real staging traffic

Workspace contract: paths, ports, and plist labels

Dimension Production Staging
Config root ~/openclaw-prod ~/openclaw-staging
Gateway listener TCP 18789 (default) TCP 18790 (explicit override)
LaunchAgent label ai.openclaw.gateway.prod ai.openclaw.gateway.staging
Log directory ~/openclaw-prod/logs ~/openclaw-staging/logs
Environment file .env.production.local (not world-readable) .env.staging.local
Throughput note: xxxMac Mac mini M4 rentals include dedicated 1 Gbps to Singapore, Tokyo, and US West POPs with provisioning in about five minutes. Dual gateways will not contend on WAN; they contend on local ports, CPU, and disk—plan log rotation aggressively when doubling daemons.

Six-step bootstrap: clone, fork ports, install, prove

  1. Freeze production: Capture openclaw status, launchctl print gui/$(id -u)/ai.openclaw.gateway.prod, and the active package version before you touch files.
  2. Filesystem clone: rsync -a --exclude logs --exclude tmp ~/openclaw-prod/ ~/openclaw-staging/; regenerate staging tokens and API keys—never copy secrets verbatim.
  3. Port & URL matrix: Edit staging config so health checks, Slack slash commands, and reverse proxies target :18790; keep production on :18789. Document both in your internal reverse-proxy repo.
  4. Install staging plist: Export OPENCLAW_CONFIG=$HOME/openclaw-staging and run openclaw gateway install --label ai.openclaw.gateway.staging (flags illustrative—match your CLI version). Reload with launchctl bootstrap per Apple guidance.
  5. Doctor both worlds: Run openclaw doctor with each config root; zero blocking errors is the bar before you attach real channels.
  6. Soak test: Send 200 synthetic events at 5 rps to staging only; watch RSS stay flat for 30 minutes while production RSS remains within ±10 % of baseline.

Permission matrix for shared-service accounts

Many teams run both gateways under one macOS user to simplify VNC handoffs. That is acceptable only with strict POSIX permissions: staging logs must not be world-readable, and production plist paths should reject group-writable bits. If finance mandates separate users, create two accounts and grant each its own ~/openclaw-* tree plus discrete SSH keys from the console.

Path class Recommended mode Notes
Config YAML / JSON 0640 Owner staff, no other write bit
Secrets directory 0750 Exclude from Time Machine if snapshots enabled accidentally
Log files 0640 with logrotate Compress after 24 hours; delete staging after 7 days

CPU scheduling: two Node gateways on one M4 without silent starvation

Apple Silicon makes single-socket contention obvious in powermetrics samples: when both gateways spike V8 garbage collection simultaneously, p95 webhook latency can climb by 180–400 ms even though each process stays below 70 % CPU. Cap staging concurrency with OPENCLAW_MAX_INFLIGHT=4 (example knob—align to your release) during production business hours, and lift the cap only in maintenance windows. If you need full-speed soak tests, temporarily unload the production LaunchAgent on a non-revenue host or move staging to a second xxxMac instance that still benefits from the same 1 Gbps uplink.

Rollback playbook when staging experiments poison shared Node caches

Global npm or pnpm stores can still collide even when configs differ. Prefer per-environment NODE_ENV and install prefixes, or containerize experimental CLIs on a second xxxMac node when upgrades involve native modules compiled against different macOS SDKs. Splitting across two hosts in Tokyo and US West also gives geographic redundancy for webhook latency experiments.

FAQ: tokens, CI hooks, and observability

Should staging call the same model provider project as production?

Use a separate cloud project or API key with spend caps; staging prompts during load tests can burn thousands of tokens in minutes.

How do we wire GitHub Actions to the right listener?

Expose staging via a distinct DNS name and TLS cert; never rely on path-based routing alone because some webhooks ignore paths when verifying signatures.

What is the fastest signal that ports collided?

lsof -nP -iTCP:18789 -sTCP:LISTEN showing two PIDs or alternating PIDs across 30 seconds means two plists are fighting—unload both, fix labels, bootstrap staging second.

Isolating OpenClaw staging from production on Apple Silicon is mostly filesystem and launchd discipline—not another layer of Kubernetes. A Mac mini M4 on xxxMac gives you enough single-threaded headroom for two modest gateways while the 1 Gbps uplink keeps webhook ACKs snappy from Singapore, Tokyo, or US West. Promote changes only after doctor checks pass in both trees; if incidents persist, fall back to the ContextEngine deployment tutorial for version-specific flags, and keep runbooks in Help Center updated with your actual plist names.

스테이징 전용 노드가 필요하신가요?

콘솔에서 M4를 추가로 프로비저닝해 프로덕션을 보호하세요.

콘솔 열기
빠른 시작
OpenClaw Runbook