im_wower
·
2026-03-26
status-launchd.sh
1#!/usr/bin/env bash
2set -euo pipefail
3
4SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5# shellcheck source=./common.sh
6source "${SCRIPT_DIR}/common.sh"
7
8usage() {
9 cat <<'EOF'
10Usage:
11 scripts/runtime/status-launchd.sh [options]
12
13Options:
14 --scope agent|daemon launchd domain type. Defaults to agent.
15 --service NAME Add one service to the status set. Repeatable.
16 --all-services Show conductor, codexd, worker-runner, and status-api.
17 --home-dir PATH Used only to derive the default LaunchAgents path.
18 --install-dir PATH Override launchd install directory.
19 --domain TARGET Override launchctl domain target. Defaults to gui/<uid> or system.
20 --local-api-base URL Conductor local API base. Defaults to http://100.71.210.78:4317
21 --codexd-api-base URL codexd local API base. Defaults to http://127.0.0.1:4319
22 --status-api-base URL Status API base. Defaults to http://100.71.210.78:4318
23 --skip-http Skip HTTP probes.
24 --help Show this help text.
25
26Notes:
27 If no service is specified, conductor + codexd are shown.
28 Use --service status-api to inspect the optional local read-only observer.
29 conductor HTTP status also reports /v1/codex to surface codexd proxy wiring.
30 codexd HTTP status only reports /healthz and /v1/codexd/status.
31 /v1/codexd/runs* is not treated as a formal runtime probe.
32EOF
33}
34
35require_command curl
36require_command launchctl
37require_command plutil
38
39scope="agent"
40home_dir="$(default_home_dir)"
41install_dir=""
42domain_target=""
43local_api_base="http://100.71.210.78:4317"
44codexd_api_base="${BAA_RUNTIME_DEFAULT_CODEXD_LOCAL_API}"
45status_api_base="http://100.71.210.78:4318"
46skip_http="0"
47services=()
48
49while [[ $# -gt 0 ]]; do
50 case "$1" in
51 --scope)
52 scope="$2"
53 shift 2
54 ;;
55 --service)
56 validate_service "$2"
57 if ! contains_value "$2" "${services[@]-}"; then
58 services+=("$2")
59 fi
60 shift 2
61 ;;
62 --all-services)
63 while IFS= read -r service; do
64 if ! contains_value "$service" "${services[@]-}"; then
65 services+=("$service")
66 fi
67 done < <(all_services)
68 shift
69 ;;
70 --home-dir)
71 home_dir="$2"
72 shift 2
73 ;;
74 --install-dir)
75 install_dir="$2"
76 shift 2
77 ;;
78 --domain)
79 domain_target="$2"
80 shift 2
81 ;;
82 --local-api-base)
83 local_api_base="$2"
84 shift 2
85 ;;
86 --codexd-api-base)
87 codexd_api_base="$2"
88 shift 2
89 ;;
90 --status-api-base)
91 status_api_base="$2"
92 shift 2
93 ;;
94 --skip-http)
95 skip_http="1"
96 shift
97 ;;
98 --help)
99 usage
100 exit 0
101 ;;
102 *)
103 die "Unknown option: $1"
104 ;;
105 esac
106done
107
108validate_scope "$scope"
109
110if [[ "${#services[@]}" -eq 0 ]]; then
111 while IFS= read -r service; do
112 services+=("$service")
113 done < <(default_node_verification_services)
114fi
115
116if [[ -z "$install_dir" ]]; then
117 install_dir="$(default_install_dir "$scope" "$home_dir")"
118fi
119
120if [[ -z "$domain_target" ]]; then
121 domain_target="$(default_domain_target "$scope")"
122fi
123
124for service in "${services[@]}"; do
125 label="$(service_label "$service")"
126 plist_path="$(service_install_path "$install_dir" "$service")"
127
128 printf '=== %s ===\n' "$service"
129 printf 'label: %s\n' "$label"
130 printf 'plist: %s\n' "$plist_path"
131
132 if [[ -f "$plist_path" ]] && plutil -lint "$plist_path" >/dev/null 2>&1; then
133 printf 'plist_lint: ok\n'
134 elif [[ -f "$plist_path" ]]; then
135 printf 'plist_lint: invalid\n'
136 else
137 printf 'plist_lint: missing\n'
138 fi
139
140 if launchctl print "${domain_target}/${label}" >/dev/null 2>&1; then
141 printf 'launchd: loaded\n'
142 else
143 printf 'launchd: not_loaded\n'
144 fi
145
146 printf '\n'
147done
148
149if [[ "$skip_http" != "1" ]]; then
150 for service in "${services[@]}"; do
151 case "$service" in
152 conductor)
153 printf '=== conductor http ===\n'
154 printf 'healthz: '
155 curl -fsS "${local_api_base%/}/healthz" || true
156 printf '\nrolez: '
157 curl -fsS "${local_api_base%/}/rolez" || true
158 printf '\n/v1/codex: '
159 curl -fsS "${local_api_base%/}/v1/codex" || true
160 printf '\n\n'
161 ;;
162 codexd)
163 printf '=== codexd http ===\n'
164 printf 'healthz: '
165 curl -fsS "${codexd_api_base%/}/healthz" || true
166 printf '\n/v1/codexd/status: '
167 curl -fsS "${codexd_api_base%/}/v1/codexd/status" || true
168 printf '\n\n'
169 ;;
170 status-api)
171 printf '=== status-api http ===\n'
172 printf 'healthz: '
173 curl -fsS "${status_api_base%/}/healthz" || true
174 printf '\n/v1/status: '
175 curl -fsS "${status_api_base%/}/v1/status" || true
176 printf '\n\n'
177 ;;
178 esac
179 done
180fi