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

Function generateSystemdUnit

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

Source from the content-addressed store, hash-verified

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