← Back to Docs

Recipe: systemd unit file writer

Generate and deploy a systemd service unit for Meridian agents on Linux endpoints. This recipe covers templating, validation, and atomic install with rollback on failure.

Prerequisites

  • Meridian agent binary installed at /opt/meridian/agent
  • systemd ≥ 245 (systemctl --version)
  • Root or sudo access for unit deployment

Unit template

[Unit]
Description=Meridian Agent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/opt/meridian/agent --config /etc/meridian/agent.toml
Restart=always
RestartSec=10
User=meridian
Group=meridian
ProtectSystem=strict
ProtectHome=true
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Deployment steps

  1. Write unit to /etc/systemd/system/meridian-agent.service
  2. Run systemctl daemon-reload
  3. Enable with systemctl enable meridian-agent
  4. Start with systemctl start meridian-agent
  5. Verify: systemctl status meridian-agent

Rollback

If the agent fails to start, systemd will retry per RestartSec. To revert, stop and disable the unit, then restore the previous binary and config from your backup path.