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

Function generateSystemdUnit

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

Source from the content-addressed store, hash-verified

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