SystemD Units and Unit types

Опубликовано: 31 Май 2020
на канале: Infinite Linux
719
9

  / awshandson  

Welcome back to the channel and in this video, we are going to continue our discussion on SystemD and will focus on systemd units and unit type.

So in the last video, I told u that the target is like a run level in SystemD and just like in a run level you have a set of services that start depending upon the run-level in which the system boots similarly in SystemD, to achieve a state of any target - a certain number of services or unit need to be up for the system to be in the state defined by the target.

So you can compare units to services or processes in the traditional SysVinit system but units are not only limited to services in SystemD, there are different types of units

Looking at the man page you can see the different types of units which are available in systemd.

Every unit has a configuration file that is required to configure it and that file is called unit file.
The system managed units, unit files are can be found in /usr/lib/systemd/system

For user managed units, you would find the unit files in /etc/systemd/system

Almost 99 percent of the time you would be dealing with service type unit, so we would also concentrate our discussion to the service unit

In order to list all the service unit file, we can use

systemctl list-unit-file --type=service

You can see that the config file have a prefix of .service indicating that it is a service type unit file, in a similar way different unit types have different prefix indicating their types

Now let's look at one of these files to understand it's autonomy
A unit file is structured in sections in a key-value type of format

After indicates the ordering - that current unit activates after the given units

the service can be of different types

simple: The main process of the service is specified in the start line. This is the default if the Type= and Busname= directives are not set, but the ExecStart= is set. Any communication should be handled outside of the unit through a second unit of the appropriate type (like through a .socket unit if this unit must communicate using sockets).

forking: This service type is used when the service forks a child process, exiting the parent process almost immediately. This tells systemd that the process is still running even though the parent exited.

one-shot: This type indicates that the process will be short-lived and that systemd should wait for the process to exit before continuing on with other units. This is the default Type= and ExecStart= are not set. It is used for one-off tasks.

dbus: This indicates that the unit will take a name on the D-Bus bus. When this happens, systemd will continue to process the next unit.

notify: This indicates that the service will issue a notification when it has finished starting up. The systemd process will wait for this to happen before proceeding to other units.

idle: This indicates that the service will not be run until all jobs are dispatched. https://amzn.to/2A9DVv1

https://amzn.to/3cEGVNf


Смотрите видео SystemD Units and Unit types онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Infinite Linux 31 Май 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 719 раз и оно понравилось 9 людям.