phase: 02-operations-maintenance
plan: "03"
subsystem: deploy
tags: [cross-platform, bash, deploy, macOS, Linux]
dependency_graph:
requires: []
provides: [cross-platform-deploy]
affects: [deploy_rkl.sh]
tech_stack:
added: []
patterns: [OS detection via uname, platform-adaptive helper functions, configurable env vars]
key_files:
created: []
modified: [deploy_rkl.sh]
decisions:
- "pg_cmd() abstraction chosen over inline if/else at each psql call site — DRY, readable"
- "VENV_PIP configurable via env var with clear error message — zero config for standard Linux, flexible for macOS"
- "macOS svc_restart() warns instead of failing — on macOS dev setups services are managed differently"
metrics:
duration_minutes: 5
completed_date: "2026-03-24"
tasks_completed: 1
files_modified: 1
Phase 02 Plan 03: Cross-Platform deploy_rkl.sh Summary
One-liner: Added OS detection via uname -s and four platform-adaptive helper functions (pg_cmd, svc_restart, svc_active, nginx_reload) that replace all Linux-only calls in deploy_rkl.sh, making it work on both macOS and Linux without manual edits.
What Was Built
deploy_rkl.sh was previously Linux/systemd-only. It used sudo -u postgres psql, systemctl, journalctl, and hardcoded /etc/nginx/sites-available paths. These were incompatible with macOS development environments.
The script now:
-
Detects the OS via
uname -sat startup and sets$PLATFORMtomacosorlinux. Unsupported platforms exit immediately with an error message. -
Provides helper functions that branch on
$PLATFORM: pg_cmd()— runssudo -u postgres psqlon Linux, plainpsqlon macOSsvc_restart()— runssystemctl restarton Linux, warns to restart manually on macOSsvc_active()— runssystemctl is-activeon Linux, usespgrepon macOS-
nginx_reload()— usessystemctl reload nginxon Linux,nginx -s reloadon macOS -
Uses
$NGINX_SITESvariable set to/etc/nginx/sites-availableon Linux or/opt/homebrew/etc/nginx/serverson macOS. The symlink step (sites-enabled) is Linux-only. -
Makes
VENV_PIPconfigurable via environment variable with fallback to/opt/crumbforest/venv/bin/pip, with a clear warning when the path doesn't exist. -
Conditionalizes
journalctl— on macOS, prints a manual instruction instead.
Tasks
| Task | Name | Commit | Files |
|---|---|---|---|
| 1 | Add OS detection and platform-adaptive commands | 4dc8666 | deploy_rkl.sh |
Deviations from Plan
None — plan executed exactly as written.
Known Stubs
None — all platform branches are functional. macOS svc_restart intentionally warns instead of acting (no systemd on macOS; developer is expected to manage the process differently).
Self-Check: PASSED
- deploy_rkl.sh exists: FOUND
- Commit 4dc8666 exists: FOUND
- bash -n deploy_rkl.sh: PASSED
- grep uname: FOUND
- grep PLATFORM: FOUND
- grep Darwin: FOUND
- grep Linux: FOUND
- grep pg_cmd: FOUND