I’m surprised about the amount of people not happy with SystemD and don’t even know how Unit files works. So as a personal note and as a way to propagate this simple information, here’s an example.
It’s almost always a bad idea to make the service unit “system-wide” when creating one for a particual use-case. So here’s my user service unit exemple for Snac.
# file: ~/.config/systemd/user/snac.service
----------------------------------------
[Unit]
Description=Snac Activity Pub Server
[Service]
Type=simple
StandardOutput=journal
ExecStart=/bin/sh -c "snac httpd /home/me/snac-data"
KillSignal=SIGINT
[Install]
WantedBy=default.target
- Start the service;
systemctl --user start snac.service
. - Enable the service;
systemctl --user enable snac.service
. - Check the service logs;
journalctl --user -u snac.service -e
. - Update the service if we edit it afterward;
systemctl --user daemon-reload
. - Keep the service running after user logout;
loginctl enable-linger
.
And that’s it.