MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / generateSystemdUnit

Function generateSystemdUnit

apps/cli/src/service.ts:440–462  ·  view source on GitHub ↗
(options: SystemdUnitOptions)

Source from the content-addressed store, hash-verified

438
439/** Render a systemd --user unit. Pure (snapshot-tested). */
440export const generateSystemdUnit = (options: SystemdUnitOptions): string => {
441 const execStart = options.execStart.map(systemdQuote).join(" ");
442 const env = Object.entries(options.environment)
443 .map(([key, value]) => `Environment=${systemdQuote(`${key}=${value}`)}`)
444 .join("\n");
445 return `[Unit]
446Description=Executor supervised daemon
447After=default.target
448
449[Service]
450Type=simple
451ExecStart=${execStart}
452${env}
453WorkingDirectory=${systemdQuote(options.workingDirectory)}
454StandardOutput=${systemdQuote(`append:${options.stdoutPath}`)}
455StandardError=${systemdQuote(`append:${options.stderrPath}`)}
456Restart=on-failure
457RestartSec=5s
458
459[Install]
460WantedBy=default.target
461`;
462};
463
464const makeSystemdBackend = (): ServiceBackend => {
465 const unitName = `${SERVICE_LABEL}.service`;

Callers 3

service.test.tsFile · 0.90
makeSystemdBackendFunction · 0.85

Calls 1

systemdQuoteFunction · 0.85

Tested by

no test coverage detected