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

Function start

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

Source from the content-addressed store, hash-verified

121 }
122
123 async function start(): Promise<LifecycleResult> {
124 const plistPath = deps.plistPath();
125 if (!existsSync(plistPath)) {
126 return {
127 ok: false,
128 message: 'LaunchAgent is not installed. Run `kimi server install` first.',
129 };
130 }
131 const target = `${deps.guiDomain()}/${KIMI_SERVER_LABEL}`;
132
133 const result = await deps.execLaunchctl(['kickstart', '-k', target]);
134 if (result.code !== 0) {
135
136 const bootstrap = await deps.execLaunchctl(['bootstrap', deps.guiDomain(), plistPath]);
137 if (bootstrap.code !== 0 && !isAlreadyLoaded(bootstrap)) {
138 return {
139 ok: false,
140 message: `launchctl kickstart + bootstrap both failed: ${detail(result) ?? 'unknown'} / ${detail(bootstrap) ?? 'unknown'}`,
141 };
142 }
143 const retry = await deps.execLaunchctl(['kickstart', target]);
144 if (retry.code !== 0) {
145 return {
146 ok: false,
147 message: `launchctl kickstart failed after bootstrap: ${detail(retry) ?? 'unknown error'}`,
148 };
149 }
150 }
151 return { ok: true, message: `Kimi server started (${KIMI_SERVER_LABEL}).` };
152 }
153
154 async function stop(): Promise<LifecycleResult> {
155 const target = `${deps.guiDomain()}/${KIMI_SERVER_LABEL}`;

Callers

nothing calls this directly

Calls 5

isAlreadyLoadedFunction · 0.85
plistPathMethod · 0.80
guiDomainMethod · 0.80
execLaunchctlMethod · 0.80
detailFunction · 0.70

Tested by

no test coverage detected