summaryrefslogtreecommitdiffstats
path: root/doc/bin/system-shutdown-daemon.html
blob: 82493b662bc9a40ed18356153b45cc33e8c872f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
	<head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    	<meta http-equiv="Content-Language" content="en" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
    	<title>system-shutdown-daemon</title>
    	<meta name="Description" content="The kernel indepentent part of the goetia shutdown procedure." />
    	<meta name="Keywords" content="goetia s6 s6-rc system supervision tree shutdown" />
	</head>
	<header>
		<p>
			<a href="//0x53.net/software/goetia/goetia-base">goetia-base</a>
			<br />
			<a href="//0x53.net/software/goetia">goetia</a>
			<br />
			<a href="//0x53.net/software">Software</a>
			<br />
			<a href="//0x53.net">0x53.net</a>
		</p>
	</header>
	<body>
		<h1>The system-shutdown-daemon program</h1>
		<p>
			system-shutdown-daemon contains the Kernel independent
			part of the shutdown sequence.
			It is invoked by the Kernel specifict goetia-shutdown service,
			e.g.
			<a href="//0x53.net/software/goetia/goetia-linux-init/service/system/goetia-shutdown.html">goetia-shutdown service for Linux</a>
			or
			<a href="//0x53.net/software/goetia/goetia-freebsd-init/service/system/goetia-shutdown.html">goetia-shutdown service for FreeBSD</a>.
			system-shutdown-daemon is a long lived program that waits for instruction by the system-shutdown command
			The latter is part of the Kernel specific packages, e.g.
			<a href="//0x53.net/software/goetia/goetia-linux">goetia-linux</a>
			or
			<a href="//0x53.net/software/goetia/goetia-freebsd">goetia-freebsd</a>.
		</p>
		<h2>Interface</h2>
		<pre>     system-shutdown-daemon</pre>
		<ul>
			<li>
    			system-shutdown-daemon takes no arguments.
			</li>
			<li>
    			It tries to execute <code>./stage3b</code>,
				which is by default not executable.
				If it can not execute <code>./stage3b</code>,
				and <em>only</em> in this case,
				it continues with the following.
			</li>
			<li>
    			All services managed by
				<a href="https://skarnet.org/software/s6-rc/">s6-rc</a>
				are stopped.
				This means, all services defined in
				<a href="https://skarnet.org/software/s6-rc/s6-rc-compile.html#source">source directories</a>
				at the <code>src</code> subdirectory of the
				<a href="//0x53.net/software/goetia/confdir.html#system">system configuration directory</a>.
			</li>
			<li>
    			Next, all leftover services <em>except</em>
				s6-svscan-log, goetia-shutdown and goetia-rescue, are stopped.
			</li>
			<li>
    			The file <code>stage3b</code>, expected to exist in the current working directory
				is made executable.
				This file is part of the Kernel secific service directories.
				(see e.g. <a href="//0x53.net/software/goetia/goetia-linux-init/service/system/goetia-shutdown.html">goetia-shutdown</a>)
			</li>
			<li>
    			all uncaught system logs are copied from the
				<code>log/uncaught-logs</code>
				subdirectory of the
				<a href="//0x53.net/software/goetia/rundir.html#system">system runtime directory</a>.
				to the
				<code>uncaught-logs</code>
				subdirectory of the
				<a href="//0x53.net/software/goetia/logdir.html#">system log directory</a>.
			</li>
			<li>
    			SIGTERM is sent to all processes but PID 1.
			</li>
			<li>
    			This also stops the system-shutdown-daemon process.
				It is automatically restarted by the system supervision tree,
				but this time, the file <code>./stage3b</code> is executable
				and executed instead of what is described above.
				What happens in <code>./stage3b</code> is Kernel specific,
				and documented on
				<a href="//0x53.net/software/goetia/goetia-linux-init/service/goetia-shutdown.html">goetia-shutdown service for Linux</a>,
				<a href="//0x53.net/software/goetia/goetia-freebsd-init/service/goetia-shutdown.html">goetia-shutdown service for FreeBSD</a>,
				etc.
			</li>
		</ul>
		<h2>Exit codes</h2>
		<ul>
			<li>
    			Since system-shutdown-daemon is an
				<a href="https://skarnet.org/software/execline/">execline</a>
				script, it exits with an approximation
				of employed program that failed.
			</li>
			<li>
    			system-shutdown-daemon mostly uses
				<a href="https://skarnet.org/software/execline/">execline</a>
				and
				<a href="https://skarnet.org/software/s6/">s6</a>
				software, the exit behaviour of which can be looked up on
				their respective pages.
			</li>
			<li>
    			See also:
				<a href="https://skarnet.org/software/execline/exitcodes.html">execline exit code handling</a>.
			</li>
		</ul>
		<h2>Options</h2>
		<ul>
			<li>
    			There are no options to system-shutdown-daemon.
			</li>
		</ul>
	</body>
</html>