11# lanchr
22
3- A macOS launch agent/daemon manager — inspect, manage, and troubleshoot launchd services.
3+ [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( LICENSE )
4+ [ ![ Platform: macOS] ( https://img.shields.io/badge/Platform-macOS-lightgrey.svg )] ( https://github.com/lu-zhengda/lanchr )
5+ [ ![ Homebrew] ( https://img.shields.io/badge/Homebrew-lu--zhengda/tap-orange.svg )] ( https://github.com/lu-zhengda/homebrew-tap )
6+
7+ macOS launch agent & daemon manager — inspect, create, and troubleshoot launchd services from the terminal.
48
59## Install
610
@@ -9,36 +13,79 @@ brew tap lu-zhengda/tap
913brew install lanchr
1014```
1115
12- ## Quick Start
16+ ## Usage
1317
14- ``` bash
15- lanchr # Launch interactive TUI
16- lanchr --help # Show all commands
18+ ```
19+ $ lanchr doctor
20+ Scanning launch agents and daemons...
21+
22+ 2 broken plists found:
23+ com.old.service — invalid XML at line 12
24+ com.removed.app — binary not found: /usr/local/bin/removed
25+
26+ 1 orphaned agent:
27+ com.uninstalled.helper — app no longer installed
28+
29+ $ lanchr list --no-apple -s running
30+ LABEL DOMAIN STATUS PID
31+ com.docker.helper user running 1234
32+ org.postgresql user running 5678
33+ com.redis.server user running 9012
1734```
1835
1936## Commands
2037
21- | Command | Description |
22- | -----------| ------------------------------------------|
23- | ` list ` | List all agents and daemons |
24- | ` info ` | Show detailed service information |
25- | ` search ` | Search services by name/label |
26- | ` enable ` | Enable a service |
27- | ` disable ` | Disable a service |
28- | ` logs ` | View service logs |
29- | ` doctor ` | Diagnose service issues |
30- | ` create ` | Create a new launch agent/daemon |
31- | ` edit ` | Edit an existing service |
32- | ` restart ` | Restart a service |
33- | ` load ` | Load a service |
34- | ` unload ` | Unload a service |
38+ | Command | Description | Example |
39+ | ---------| -------------| ---------|
40+ | ` list ` | List all services | ` lanchr list --no-apple ` |
41+ | ` list -d <domain> ` | Filter by domain (user/global/system) | ` lanchr list -d user ` |
42+ | ` list -s <status> ` | Filter by status (running/stopped/error) | ` lanchr list -s error ` |
43+ | ` info <label> ` | Detailed service info (all plist keys + runtime) | ` lanchr info com.example.myapp ` |
44+ | ` search <query> ` | Search by label, path, or content | ` lanchr search redis ` |
45+ | ` enable <label> ` | Enable a disabled service (persists) | ` lanchr enable com.example.myapp ` |
46+ | ` disable <label> ` | Disable a service (persists) | ` lanchr disable com.example.myapp ` |
47+ | ` load <path> ` | Bootstrap a plist file | ` lanchr load ~/Library/LaunchAgents/com.example.plist ` |
48+ | ` unload <label> ` | Bootout a service | ` lanchr unload com.example.myapp ` |
49+ | ` restart <label> ` | Force restart a running service | ` lanchr restart com.example.myapp ` |
50+ | ` logs <label> ` | View service logs | ` lanchr logs com.example.myapp -f ` |
51+ | ` doctor ` | Diagnose broken plists and orphaned agents | ` lanchr doctor ` |
52+ | ` create ` | Scaffold a new plist from template | See below |
53+ | ` edit <label> ` | Open plist in $EDITOR | ` lanchr edit com.example.myapp ` |
3554
36- ## TUI
55+ ### Creating Launch Agents
56+
57+ Use ` lanchr create ` with templates instead of writing plist XML manually:
58+
59+ ``` bash
60+ # Simple agent that runs a script at login
61+ lanchr create -l com.me.backup -p /usr/local/bin/backup.sh --template simple --run-at-load
3762
38- Launch without arguments for interactive mode. Browse services, filter by domain/status, and manage agents with a keyboard-driven interface.
63+ # Interval-based agent (every 30 minutes)
64+ lanchr create -l com.me.sync -p /usr/local/bin/sync.sh --template interval --interval 1800
65+
66+ # Calendar-based agent (daily at 9am)
67+ lanchr create -l com.me.report -p /usr/local/bin/report.sh --template calendar --calendar " Hour=9 Minute=0"
68+
69+ # Keep-alive agent (restart on crash)
70+ lanchr create -l com.me.server -p /usr/local/bin/server --template keepalive --keep-alive
71+
72+ # File watcher agent
73+ lanchr create -l com.me.watcher -p /usr/local/bin/process.sh --template watcher
74+ ```
75+
76+ Additional flags: ` --stdout <path> ` , ` --stderr <path> ` , ` --env KEY=VAL ` , ` --load ` (bootstrap after creation).
77+
78+ ## Diagnostic Workflow
79+
80+ 1 . ` lanchr doctor ` — identify broken plists, orphaned agents, missing binaries
81+ 2 . ` lanchr list -s error ` — find services in error state
82+ 3 . ` lanchr logs <label> -f ` — follow logs for a specific service
83+ 4 . ` lanchr restart <label> ` — restart a misbehaving service
84+
85+ ## TUI
3986
40- <!-- Screenshot placeholder:  -->
87+ Launch ` lanchr ` without arguments for interactive service management. Browse services, filter by domain/status, and manage agents with a keyboard-driven interface.
4188
4289## License
4390
44- MIT
91+ [ MIT] ( LICENSE )
0 commit comments