What this prompt does
This prompt makes the AI write a complete, production-grade systemd setup for running an application as a managed Linux service. You describe the app with [application_name], [distro], [app_type], and [listen_address], and the model generates the full unit file with the right Type= ([service_type]), ExecStart/ExecReload/ExecStop commands, and WorkingDirectory pointing at [app_directory]. It also produces the security hardening, resource limits, restart policy, optional socket and timer units, and an installer.
The structure works because it forces every part of a hardened unit to be filled in deliberately rather than left to defaults. Sandboxing directives are pinned to your [writable_paths] and [syscall_set], resource ceilings come from [memory_limit], [cpu_limit], and [task_limit], and the restart block uses StartLimitBurst/StartLimitIntervalSec so a crashing process can't loop forever. Because each placeholder maps to one real decision, the output is a unit you can drop in and trust instead of a generic template.
When to use it
- You're deploying a long-running daemon (API, worker, web server) on a Linux host and want it managed by systemd from the start.
- You need security sandboxing —
ProtectSystem=strict,NoNewPrivileges,SystemCallFilter— without memorizing every directive. - You want resource limits so one service can't starve the box of memory or CPU.
- You're chasing zero-downtime deploys and want a
.socketunit for socket activation. - You also need a scheduled task and would rather use a systemd timer than cron.
- You want a repeatable
install.shor Makefile that copies units, reloads, enables, and verifies the service.
Example output
Expect a set of file blocks: a [service_name].service unit with the security and resource sections filled in, an optional [service_name].socket, an optional timer unit, and an install script. Each is followed by the journalctl commands for tailing and filtering that service's logs, so you can deploy and confirm it's running in one pass.
Pro tips
- Get
[service_type]right: usenotifyonly if your app actually signals readiness via sd_notify; otherwisesimpleorexecis safer and avoids a hung start. - Keep
[writable_paths]as tight as possible — every path you add toReadWritePathswidens the blast radius of a compromise. - Set
[memory_limit]and[task_limit]from observed usage, not guesses; too low and systemd OOM-kills your service, too high and the limit is decorative. - Start
[syscall_set]with@system-serviceand only add families when the service fails on a real syscall — over-restrictingSystemCallFiltercauses confusing crashes. - If
[app_type]doesn't bind its own socket, drop the.socketunit rather than forcing socket activation where it doesn't fit. - After generation, run the install script on a throwaway host first and check
systemctl statusplus the journalctl output before trusting it in production.