-
Notifications
You must be signed in to change notification settings - Fork 72
Systemd
Systemd is the init system that all major Linux distributions will be using in the future.
Basic commands:
# list all services
systemctl -t service
# working with foo.service, you can leave off the ".service"
systemctl start foo
systemctl restart foo
systemctl stop foo
systemctl status foo
You can enable and disable a service if you need to. Disabled services won't start on reboot.
systemctl enable foo
systemctl disable foo
Systemd manages units; one type of unit is a service which is what we care about. User-custom unit files go in /usr/lib/systemd/system
. When you enable a service, systemd will create a symlink in /etc/systemd/system/multi-user.target.wants
. This is a way of saying "when the machine boots normally, start my service". Everything in this multi-user.target.wants directory is started on normal bootup.
Inspeqtor's service unit file in /usr/lib/systemd/system/inspeqtor.service
is well-commented and hopefully straight-forward to understand.
See your own system's /usr/lib/systemd/system
directory for more examples. I found the following two systemd man pages to be incredibly helpful:
- http://0pointer.de/public/systemd-man/systemd.service.html
- http://0pointer.de/public/systemd-man/systemd.exec.html
Services that fork (such as Nginx) need to include the PIDFile=
option in their system unit file in order for Inspeqtor to monitor them. If this option is omitted then Systemd won't be able to detect the process id and Inspeqtor will be unable to determine an accurate status.