These are the notes of a training course on systemd I gave as part of my work with Truelite.
.service units
Describe how to start and stop system services, like daemons.
Services are described in a [Service] section. The Type= configuration
describes how the service wants to be brought up:
Type=simple: a program is started and runs forever, providing the service. systemd takes care of daemonizing it properly in the background, creating a pidfile, stopping it and so on. The service is considered active as soon as it has started.Type=forking: a traditional daemons that forks itself, creates a pidfile and so on. The server is considered active as soon as the parent process ends.Type=oneshot: a program is run once, and the service is considered started after the program ends. This can be used, for example, to implement a service to do one-off configuration, like checking a file system.Type=dbus: likesimplebut for D-Bus services: the service is considered active as soon as it appears on the D-Bus bus.Type=notify: likesimple, but the service tells sytemd when it has finished initialization and is ready. Notification can happen via thesd_notifyC function, or thesystemd-notifycommand.Type=idle: likesimple, but it is run after all other services has been started on a transaction. You can use this, for example, to start a shell on a terminal after the boot, so that the prompt doesn't get flooded with boot messages, or to play a happy trumped sound after the system has finished booting.
There are a lot more configuration options to fine-tune how the program should be managed, to limit its resource access or capabilities to harden the system security, to run setup/cleanup scripts before or after it started, and after it gets stopped, to control what signals to send to ask for reload or quit, and quite a lot more.
See:
man systemd.service,
man systemd.exec,
man systemd.resource-control, and
man systemd.kill.
See systemctl --all -t service for examples.