a73x

scripts/eitri-agent.service

Ref:   Size: 2.4 KiB   History

# eitri-agent systemd unit. Install on each fleet host:
#
#   cp eitri-agent.service /etc/systemd/system/
#   systemctl daemon-reload && systemctl enable --now eitri-agent
#
# Restart=on-failure is the reviver for a crashed agent. Agent self-upgrades
# never need it: the agent re-execs in place, keeping its PID, so systemd sees
# one uninterrupted service. If an upgraded binary crashes, the restart loop
# stops at the start limit and the previous binary sits beside it as
# eitri-agent.prev for manual recovery.

[Unit]
Description=eitri agent — reconciles this host's VMs against the fleet control plane
Documentation=https://eitri.sh
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=300
StartLimitBurst=10

[Service]
# Flags (resource caps, paths) go in /etc/default/eitri-agent as
# EITRI_AGENT_FLAGS="--max-vcpus 8 ..."; the defaults suit a standard install
# (state under /var/lib/eitri-agent, cloud-hypervisor on PATH, firmware at
# /usr/share/eitri/CLOUDHV.fd). The empty Environment= default keeps systemd
# from logging an unset-variable reference when no override file exists.
Environment=EITRI_AGENT_FLAGS=
EnvironmentFile=-/etc/default/eitri-agent
ExecStart=/usr/local/bin/eitri-agent $EITRI_AGENT_FLAGS
Restart=on-failure
RestartSec=5
# KillMode=process is LOAD-BEARING: guests are cloud-hypervisor processes in
# this unit's cgroup, and the default control-group kill would tear down every
# running VM on a mere agent stop. Only the agent itself may be signalled —
# VMs survive agent restarts by design.
KillMode=process
# The agent's descriptor budget, stated rather than inherited from whatever the
# distro's default happens to be. Published guest ports are proxied inside this
# process, two descriptors per connection, and each exposure serves at most 256
# at once: dozens of saturated published ports fit here with room to spare, and
# what is left over is what the agent runs the fleet with — hypervisor children,
# disk images, consoles, the sync tunnel. Traffic on a published port must never
# be able to starve fleet management.
LimitNOFILE=65536
# Root is deliberate and scoped to THIS unit (eitri-server and eitri-oidc run
# as dedicated users): the agent opens /dev/kvm and /dev/net/tun, creates the
# bridge and taps, sets net.ipv4.ip_forward, installs the nftables masquerade,
# binds DHCP on :67, and self-upgrades by swapping its own binary in
# /usr/local/bin.
User=root

[Install]
WantedBy=multi-user.target