Some years ago ArchLinux started to use systemd instead of init scripts, I like init scripts more, but you have to adapt.
So, How to add a new service to be managed by systemd?
We'll see just the basic options, systemd has its files at: /etc/systemd/system, so if you want your service to managed by systemd, you need to create a file in that directory, you need to be root or have sudo powers.
The most basic form of a file is:
[Unit] Description = RSS collector After = network.target [Service] ExecStart = /usr/bin/miniflux -c /etc/miniflux.conf ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 [Install] WantedBy=multi-user.target
In the unit section, we have the following variables.
- Description: Pretty self explanatory
- After: Here we specify when the service will come up, in this case we are telling systemd that we want it to come up when we have Network up.
In the service section
- ExecStart: Is the command to run to start the service, in my case it is to start miniflux in my home PC
- ExecReload: What command is going to run when you ask
systemcltto reload the service.
- TimeoutSec: Self explanatory again, it will wait 15 seconds for the service to start
In the Install section
- WantedBy: Tells the system, that if we enable the service a symbolic link to that service will be created inside the multi-user.target.wants directory, and it will be deleted when we disable the service.