[systemd-devel] Service units handling naive questions
Thomas HUMMEL
thomas.hummel at pasteur.fr
Wed Jun 7 16:42:14 UTC 2023
Hello,
I'm running systemd-239-74.el8_8.x86_64 on RHEL 8.8 and have some naive
questions about services :
Note : I'm talking here only about service units
1) listing of inactive (dead) units
####################################
For instance, the following oneshot static service (as it came with the
distro):
# systemctl cat nfs-utils.service | grep -vE '^#'
[Unit]
Description=NFS server and client services
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
# systemctl status nfs-utils.service
● nfs-utils.service - NFS server and client services
Loaded: loaded (/usr/lib/systemd/system/nfs-utils.service; static;
vendor preset: disabled)
Active: inactive (dead)
shows up in the output of :
# systemctl list-units --all --type=service --state=dead
nfs-utils.service | grep -iE nfs-utils
nfs-utils.service loaded inactive dead NFS server and client services
-> why is it marked as inactive in spite of the RemainAfterExit=yes
directive ? Shouldn't it be in ACTIVE=active general state ?
b) If I create a simple oneshot static service unit, and start it:
# systemctl cat foobar.service | grep -vE '^#'
[Unit]
Description=Simple service
[Service]
ExecStart=echo "Hello !"
# systemctl status foobar.service
● foobar.service - Simple service
Loaded: loaded (/etc/systemd/system/foobar.service; static; vendor
preset: disabled)
Active: inactive (dead)
Jun 07 18:14:58 orbit systemd[1]: Started Simple service.
Jun 07 18:14:58 orbit echo[1896]: Hello !
Jun 07 18:14:58 orbit systemd[1]: foobar.service: Succeeded.
it ends up inactive (dead) but is not shown by the systemctl list-units
--all --type=service --state=dead foobar.service command :
# systemctl list-units --all --type=service --state=dead foobar.service
0 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
c) it does if I turn it into an [Install]-able service and enable it
Could you help me figuring out what logic I am missing ? Does the
command list only enabled units ?
2) Removing a template unit while instances are still running
#############################################################
a) I have a socket-activated sa-sshd at .service template unit (running
sshd -i) which works fine but I experience many (a lot) of failed
instances which I have to systemctl reset-failed sa-sshd@'*' just for
the sake of cleaning up or just having systemctl status completion
working smoothly
-> is there some way to do it in a smarter way (providing I don't care
to investigate the failed instances) ?
b) I want to switch from a) to just systemd-socket-proxyd the socket to
standard non socket activated sshd.service
To migrate, as I see a couple of active sa-sshd at xxx.service instances,
and assuming new socket activation won't be triggered while I am
migrating, is it safe to remove the template unit (+ daemon-reload),
hence turning instances LOADED state to not-found or will it do
something to the running instances ?
Thanks for your help
--
Thomas HUMMEL
More information about the systemd-devel
mailing list