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

Function install

packages/server/src/svc/systemd.ts:56–95  ·  view source on GitHub ↗
(args: InstallArgs)

Source from the content-addressed store, hash-verified

54 const deps: SystemdManagerDeps = { ...DEFAULT_DEPS, ...overrides };
55
56 async function install(args: InstallArgs): Promise<InstallResult> {
57 const unitPath = deps.unitPath();
58 const logPath = deps.logPath();
59 const program = deps.resolveProgram();
60 const plan = buildInstallPlan({ ...args, program, logPath });
61
62 const alreadyInstalled = existsSync(unitPath);
63 if (alreadyInstalled && args.force !== true) {
64 return {
65 status: 'already-installed',
66 message: `systemd unit already installed at ${unitPath}. Rerun with --force to replace it.`,
67 unitPath,
68 };
69 }
70
71 await assertUserSystemdAvailable(deps);
72
73 writeUnit(unitPath, plan);
74 writeInstallPlan(plan);
75
76 const reload = await deps.execSystemctl(['daemon-reload']);
77 if (reload.code !== 0) {
78 throw new Error(
79 `systemctl --user daemon-reload failed (code ${reload.code}): ${detail(reload) ?? 'unknown error'}`,
80 );
81 }
82
83 const enable = await deps.execSystemctl(['enable', '--now', KIMI_SERVER_SYSTEMD_UNIT]);
84 if (enable.code !== 0) {
85 throw new Error(
86 `systemctl --user enable --now failed (code ${enable.code}): ${detail(enable) ?? 'unknown error'}`,
87 );
88 }
89
90 return {
91 status: alreadyInstalled ? 'replaced' : 'installed',
92 message: `Kimi server systemd unit ${alreadyInstalled ? 'replaced' : 'installed'} at ${unitPath} (port ${plan.port}).`,
93 unitPath,
94 };
95 }
96
97 async function uninstall(): Promise<LifecycleResult> {
98 const unitPath = deps.unitPath();

Callers

nothing calls this directly

Calls 9

buildInstallPlanFunction · 0.90
writeInstallPlanFunction · 0.90
writeUnitFunction · 0.85
unitPathMethod · 0.80
execSystemctlMethod · 0.80
detailFunction · 0.70
logPathMethod · 0.65
resolveProgramMethod · 0.65

Tested by

no test coverage detected