macos-launchd-service

Configure persistent macOS services with launchd watchdogs and Colima containerized datastores.

Updated May 28, 2026
One-click install
npx skills add https://github.com/patty-chow/the-stable --skill macos-launchd-service-patty-chow
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: macos-launchd-service
Source: https://github.com/patty-chow/the-stable/tree/main/skills/devops/macos-launchd-service
Command: npx skills add https://github.com/patty-chow/the-stable --skill macos-launchd-service-patty-chow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymongo, and includes scripts (resource) and references (resource) components.

What problem does it solve? macOS services that self-daemonize (spawning a child then exiting) defeat launchd's KeepAlive supervision, leaving orphaned processes that never restart after crashes or reboots. This Skill provides the watchdog pattern, plist templates, and container recipes needed to run persistent daemons and local databases reliably on macOS. ## Core Features & Use Cases - Watchdog Pattern for launchd: Wrap self-daemonizing CLI tools in a health-check script that stays alive while the service runs and exits when it dies, triggering launchd restart. - LaunchAgent Deployment: Plist templates, load/bootstrap commands, and fixes for macOS Sequoia speculative deferral and other common pitfalls. - Containerized Local Services: Colima/Docker recipes for databases like DocumentDB, including the INIT_DATA crash-loop fix, named-volume persistence, and a dual-write storage layer that survives DB outages. - Use Case: You want the Hermes dashboard to auto-start at login and auto-restart on crash. Deploy the watchdog script plus plist, kickstart the agent, and verify with launchctl print. ## Quick Start Ask the agent to set up a persistent launchd service for a local dashboard on port 9119 using the watchdog template and verify it is running.

Frequently Asked Questions about macos-launchd-service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep a macOS service running after reboot with launchd?▼

Create a LaunchAgent plist in ~/Library/LaunchAgents with RunAtLoad and KeepAlive set to true, then load it with launchctl load. Point ProgramArguments at a watchdog script rather than the service binary directly.

Why does launchd show my service as not running even though it started?▼

Self-daemonizing tools spawn a child and exit the parent with code 0, so launchd marks the job done and stops tracking it. Wrap the command in a watchdog script that polls a health URL and only exits when the service dies.

How do I run Docker containers on macOS without Docker Desktop?▼

Install Colima and the Docker CLI via Homebrew, then run colima start to create the VM. Use brew services start colima for login auto-start and docker run with --restart unless-stopped for persistent containers.

Why does my DocumentDB container crash-loop on restart?▼

The documentdb-local image re-runs its seed scripts on every start, hits duplicate key errors, and exits non-zero. Recreate the container with -e INIT_DATA=false -e SKIP_INIT_DATA=true and a named volume; the CLI flag is rejected by this image.

How do I write to a database without breaking when it is down?▼

Use the dual-write pattern: append to a JSONL file first as the durable floor, then mirror to the DB inside a try/except. Reads try the DB with a short serverSelectionTimeoutMS and fall back to the JSONL file on any error.

What is the fix for launchd speculative deferral on macOS Sequoia?▼

After launchctl load, the agent may sit in state not running with pended nondemand spawn set to speculative. Run launchctl kickstart -k gui/$(id -u)/<label> to force the start; subsequent reboots usually start it normally.