A systemd service is an .ini file in /etc/systemd/system/. The minimum to run
a command at startup:
# /etc/systemd/system/myapp.service
[Unit]
Description=My app
After=network-online.target
[Service]
ExecStart=/usr/local/bin/myapp
Restart=on-failure
[Install]
WantedBy=multi-user.target
After creating or editing, reload and enable:
sudo systemctl daemon-reload
sudo systemctl enable --now myapp.service
enable creates the link that starts it at boot (via WantedBy); --now starts
it right away. Type=oneshot + RemainAfterExit=yes in [Service] is for
scripts that bring something up and exit (e.g. docker compose up -d) but should
count as “active”.