How to create a custom service that will autostart on boot on Archlinux?
Solution 1:
Try this:
[Unit]
Description=Fatrat NoGui Web Access Service
Requires=network.target
After=network.target
[Service]
ExecStart=/usr/bin/fatrat -n
Type=forking
[Install]
WantedBy=multi-user.target
I assumed, that a "Web Access Service" needs network, so I added network.target as a requirement.
Using nohup is unnecessary because this functionality is provided by systemd itself, same for the '&'.
Because we don't use nohup anymore, the type would change to simple, however, the web interface available on the git release won't work unless we make it forking.
For more information on systemd service files see the "systemd.service" man page and https://wiki.archlinux.org/index.php/Systemd#Writing_custom_.service_files
You might consider to add
Restart=always
to the[Service]
section to get it restarted automatically if it crashes.Put the service file at
/etc/systemd/system/fatrat.service
and enable it for automatic startup viasystemctl enable fatrat.service