(options: SystemdUnitOptions)
| 438 | |
| 439 | /** Render a systemd --user unit. Pure (snapshot-tested). */ |
| 440 | export 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] |
| 446 | Description=Executor supervised daemon |
| 447 | After=default.target |
| 448 | |
| 449 | [Service] |
| 450 | Type=simple |
| 451 | ExecStart=${execStart} |
| 452 | ${env} |
| 453 | WorkingDirectory=${systemdQuote(options.workingDirectory)} |
| 454 | StandardOutput=${systemdQuote(`append:${options.stdoutPath}`)} |
| 455 | StandardError=${systemdQuote(`append:${options.stderrPath}`)} |
| 456 | Restart=on-failure |
| 457 | RestartSec=5s |
| 458 | |
| 459 | [Install] |
| 460 | WantedBy=default.target |
| 461 | `; |
| 462 | }; |
| 463 | |
| 464 | const makeSystemdBackend = (): ServiceBackend => { |
| 465 | const unitName = `${SERVICE_LABEL}.service`; |
no test coverage detected