mac-watchdog
Installation
SKILL.md
mac-watchdog
A frozen Mac leaves almost nothing behind. macOS logs that memory ran out, not what used it, and a long enough freeze makes it kill WindowServer, which logs the user out and closes every app. This skill runs two launchd jobs that record what happens and step in before the freeze.
| Job | Runs as | Does |
|---|---|---|
dev.dotai.mac-watchdog |
the user | Records memory every 10 seconds and stops runaway processes |
dev.dotai.mac-watchdog.fseventsd |
root | Restarts fseventsd when its leak passes 1 GB |
They are two jobs because restarting fseventsd needs root, and a root job must never run a file the user can edit, such as Node or the recorder. Both write to ~/Library/Logs/mac-watchdog/.
<skill> is this skill's base directory.
Install, update or remove
- To install the recorder, or to apply an edit to
scripts/recorder.mjs, runzsh <skill>/scripts/install.sh. It needs no sudo. It copies the recorder to~/Library/Application Support/mac-watchdog, compiles thefootprinthelper withcc, writes~/Library/LaunchAgents/dev.dotai.mac-watchdog.plistwith thenodeon PATH, starts the job and prints the first sample. It refuses when another recorder already runs, and whenccis missing, whichxcode-select --installfixes. It also removes the job ofmem-log, this skill's old name, and moves its logs here. Done when it prints a sample line. - To install the fseventsd watchdog, or to apply an edit to
scripts/fseventsd.sh, the user runssudo zsh <skill>/scripts/install-fseventsd.sh, because it needs root; give them the command. It copies the watchdog to/usr/local/sbinas root-owned, writes/Library/LaunchDaemons/dev.dotai.mac-watchdog.fseventsd.plist, removes the job offseventsd-watchdog, this part's old name, starts the job, then prints its log, fseventsd's memory and the leak's onset line from the last 7 days (event table has grown too large). - To remove them, run
zsh <skill>/scripts/install.sh uninstallandsudo zsh <skill>/scripts/install-fseventsd.sh uninstall. The logs stay.