MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / renderSystemdUnit

Function renderSystemdUnit

packages/codex-native-api/src/daemon_manager.ts:438–481  ·  view source on GitHub ↗
({
  description,
  envFile,
  launchSpec,
  supervisorArgs,
  pathEnv,
  homeDir,
  userName,
  logName,
}: {
  description: string;
  envFile: string;
  launchSpec: SelfLaunchSpec;
  supervisorArgs: string[];
  pathEnv: string;
  homeDir: string;
  userName: string;
  logName: string;
})

Source from the content-addressed store, hash-verified

436}
437
438export function renderSystemdUnit({
439 description,
440 envFile,
441 launchSpec,
442 supervisorArgs,
443 pathEnv,
444 homeDir,
445 userName,
446 logName,
447}: {
448 description: string;
449 envFile: string;
450 launchSpec: SelfLaunchSpec;
451 supervisorArgs: string[];
452 pathEnv: string;
453 homeDir: string;
454 userName: string;
455 logName: string;
456}): string {
457 const execStart = quoteSystemdExecStart(launchSpec.command, supervisorArgs);
458 return [
459 '[Unit]',
460 `Description=${description}`,
461 'After=network-online.target',
462 'Wants=network-online.target',
463 '',
464 '[Service]',
465 'Type=simple',
466 `WorkingDirectory=${launchSpec.workingDirectory}`,
467 `Environment=HOME=${homeDir}`,
468 `Environment=USER=${userName}`,
469 `Environment=LOGNAME=${logName}`,
470 `Environment=PATH=${pathEnv}`,
471 `EnvironmentFile=${envFile}`,
472 `ExecStart=${execStart}`,
473 'Restart=always',
474 'RestartSec=2',
475 'KillMode=process',
476 '',
477 '[Install]',
478 'WantedBy=default.target',
479 '',
480 ].join('\n');
481}
482
483export function renderLaunchdPlist({
484 label,

Callers 1

buildDaemonInstallPlanFunction · 0.85

Calls 1

quoteSystemdExecStartFunction · 0.85

Tested by

no test coverage detected