MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / status

Function status

packages/server/src/svc/launchd.ts:182–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180 }
181
182 async function status(): Promise<ServiceStatus> {
183 const plistPath = deps.plistPath();
184 const plan = readInstallPlan();
185 const installed = existsSync(plistPath);
186
187 const base: ServiceStatus = {
188 platform: 'darwin',
189 installed,
190 running: false,
191 label: KIMI_SERVER_LABEL,
192 ...(plan?.host !== undefined ? { host: plan.host } : {}),
193 ...(plan?.port !== undefined ? { port: plan.port } : {}),
194 logPath: deps.logPath(),
195 };
196
197 if (!installed) {
198 return { ...base, notes: ['LaunchAgent is not installed.'] };
199 }
200
201 const print = await deps.execLaunchctl(['print', `${deps.guiDomain()}/${KIMI_SERVER_LABEL}`]);
202 if (print.code !== 0) {
203 return {
204 ...base,
205 notes: [
206 `launchctl print failed (code ${print.code}): ${detail(print) ?? 'unknown'}.`,
207 'The plist is on disk but the service is not loaded.',
208 ],
209 };
210 }
211 const info = parseLaunchctlPrint(print.stdout);
212 const notes =
213 info.state !== undefined
214 ? [`launchd state: ${info.state}`]
215 : ['launchd state: unknown'];
216 if (info.lastExitCode !== undefined) {
217 notes.push(`last exit code: ${info.lastExitCode}`);
218 }
219 return {
220 ...base,
221 running: info.state === 'running' || info.pid !== undefined,
222 ...(info.pid !== undefined ? { pid: info.pid } : {}),
223 notes,
224 };
225 }
226
227 return { install, uninstall, start, stop, restart, status };
228}

Callers

nothing calls this directly

Calls 8

readInstallPlanFunction · 0.90
parseLaunchctlPrintFunction · 0.85
plistPathMethod · 0.80
execLaunchctlMethod · 0.80
guiDomainMethod · 0.80
detailFunction · 0.70
logPathMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected