Debian Codegraph @

notes/NOTES.md

raw
1 # Not A Daemon
2
3 The real systemd environment is based on a central daemon that
4 the "systemctl" command talks to. That one loads the unit files
5 on disk into memory (hence "systemctl daemon-reload").
6
7 That one allows some features that "systemctl.py" can not
8 provide at all.
9
10 ## Restart=on-failure
11
12 The daemon can watch over its spawned processes (especially with
13 Type=simple) which allows it to automatically restart them if
14 the user wants to.
15
16 Restart=on-failure
17
18 Restart=always
19 RestartSec=3
20
21 These things will probably never be supported with "systemctl.py".
22 One would need to run some background program somehow. Perhaps it
23 would be an option when running as the init-process but it is
24 currently not a goal for the 1.0 release.
25
26 ## /var/run/unit.service.pid
27
28 The daemon will also know the PID of its spawned processes (again
29 with Type=simple) and the list is really just kept in memory. The
30 "systemctl.py" needs to store all operational information however
31 on disk.
32
33 As such, every process that does not specify a "PIDFile=" in the
34 unit descriptor will nethertheless get a pid file on disk. By
35 convention it uses the filename of the unit descriptor with an
36 attached ".pid" and it is stored in /var/run where most services
37 will store their pid file anyway.
38
39 So when the is-active attribute is asked then "systemctl.py" will
40 really look into that pid-file and check if the pid is alive. It
41 is that simple. (If the unit file declares a PIDFile then the pid
42 from that one is read - hopefully in a format that one can
43 understand.)
44
45 ## /var/log/journal/etc.unit.service.log
46
47 Likewise one can just store the output of the child processes in
48 memory so the output is diverted into /var/log/journal/. That
49 directory would also used by the systemd daemon but in a different
50 way. So far there is no need to adapt the format.
51
52 Looking at the style of journalctl is yet another thing that one
53 could think about for systemctl.py after the 1.0 release.
54
55 ## new substate via NOTIFY_SOCKET
56
57 The current "systemctl.py" script has actually implemented a good
58 portion of the $NOTIFY_SOCKET sd_notify portion. However that one
59 is only used to implement a dynamic waiting time for the process
60 to start. So it creates a /var/run/systemd/notify socket and then
61 it reads from that socket until "READY=1" is seen.
62
63 As soon as READY is received, the systemctl.py will end and with
64 it the notify-socket is removed. A real notify-socket programm
65 may however send attributes to the running systemd-daemon - and
66 most importantly the substate can give an overview on the health
67 of a system.
68
69 Since the next notify-socket will only exist on Restart, there is
70 no chance for that with "systemctl.py"
71
72 # Not A Network
73
74 The "systemctl.py" script is commonly used in a docker container,
75 hence the project name "docker-systemctl-replacement". For a
76 docker container however all the network setup is managed on the
77 outside of the container - you do have an emulated "eth0" but
78 that's as much as you can do. And you should leave it alone anyway.
79
80 Quite a number of service unit files however declare dependencies
81 on some network feature. We do have to ignore them all. Likewise
82 any existing unit file relating to network stuff - including some
83 firewall rules - has to be disregarded compeletely.
84
85 This however follows some heuristic assumptions. Some unit files
86 are skipped.... but may be that will be found to be wrong in the
87 future. Or may be some other unit descriptor needs to be skipped
88 as well.
89
90 ## Not A Volume Manager
91
92 The same applies to the management of volumes. That is a thing
93 that the docker daemon will do for you. So any program with such
94 a feature needs to told to not do anything. That is most
95 importantly for applications handling backup operations.
96
97 Simply assume that no special disk operations can be done in a
98 container. And hopefully the application does not require selinux
99 to be present.
100
101 ## No Remote SystemD
102
103 Quite a number of the options for a real "systemctl" are about
104 not connecting to the local system daemon, but pointing to
105 a different machine. Or to a systemd inside a container. Or to
106 a systemd subprocess for specific user.
107
108 That is not supported by "systemctl.py" and those options have
109 been removed completely from the commandline interface. Any
110 program trying to use these should fail early with our
111 docker-systemctl-replacement program.
112
113 # Usage Without Docker
114
115 Whereas the "systemctl.py" is commonly used to be run inside a
116 docker container, it does still have some good points in a
117 normal system - even in parallel with normal "systemctl".
118
119 That is because "systemctl.py" can check the validity of the
120 unit.service files around. It's internal logic does understand
121 quite a lot of the features that lie therein. And so if the
122 "systemctl.py" does not like a thing that is probably also
123 wrong for a real system process.
124
125 ## Check with --root=path
126
127 Most importantly that is used for its own testsuite.py - the first
128 half of the tests will create a tmp.xxxx subdirectory where some
129 generated x.service files are stored. Then the option --root=path
130 is used to inspect their content if they are okay as a whole.
131
132 Notably, the --root=path feature is also known to the real
133 "systemctl" program. But most people will not likely have used
134 it before - it is meant to configure a chroot-environment with
135 the general systemd daemon.
136
137 And if you run "systemctl.py" without a --root=path then it will
138 just look at the current system as it is. Which may reveal some
139 interesting things you have never noticed before.
140