From cbaecd3f58f99fef36bfde420e09e33d24bb9fd8 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 2 Sep 2021 16:52:11 +0200 Subject: [PATCH] Update notes --- notes/buses.md | 3 ++ notes/control-commands.md | 93 ++++++++++++++++++++++++++++++++++++ notes/init.md | 12 +++++ notes/logging.md | 18 +++++++ notes/process-supervision.md | 9 ++++ 5 files changed, 135 insertions(+) create mode 100644 notes/control-commands.md create mode 100644 notes/logging.md diff --git a/notes/buses.md b/notes/buses.md index ed43033..a55d00d 100644 --- a/notes/buses.md +++ b/notes/buses.md @@ -7,3 +7,6 @@ DBus - https://www.freedesktop.org/wiki/Software/dbus/ ubus (openwrt) - https://oldwiki.archive.openwrt.org/doc/techref/ubus - ACLs +plumber (plan9!) - http://man.cat-v.org/plan_9/4/plumber + - data format "plumb" http://man.cat-v.org/plan_9/6/plumb + - autostarts listeners on request diff --git a/notes/control-commands.md b/notes/control-commands.md new file mode 100644 index 0000000..fea6c3c --- /dev/null +++ b/notes/control-commands.md @@ -0,0 +1,93 @@ +--- +title: 'System control commands' +--- + +## systemctl + +Commands generally accept patterns to select subsets of the set of all +units. + + - list-units + - list-sockets + - list-timers + - is-active (predicate over units) + - is-failed + - status + - show + - cat (introspection on source files for units) + - help (this is interesting!) + - list-dependencies + + - start + - stop + - reload ("please reload your configuration" - even though we are + mostly reactive, most services won't be, and sometimes config in + files exists etc) + - restart (stop (if running) and then start (unconditionally)) + - try-restart (if running, stop and then start) + - reload-or-restart, try-reload-or-restart + - isolate (effectively set a new "supergoal", removing all others. nb `AllowIsolate` flag) + - kill + - clean (remove various cache/state/config/log data) + - freeze, thaw + - set-property (for us, change a config .pr file; no --runtime equivalent, though) + - reset-failed (resets the state variables of the supervisor) + - (several others) + +Enable vs start. + +Enable: `--system`, `--user`, `--runtime`, `--global`: various scopes for enabling a unit. + +Container management. + +Job management. (It has a job queue!) + +Environment management for spawned services. + +`daemon-reexec`, serializes state for an upgrade + +System lifecycle: startup -> running -> (shutdown | (maintenance -?-> running)) + +At shutdown or sleep, "inhibitor locks" exist. The action can respect +or ignore these. Interactive shutdown/sleep requests default to +respecting; non-interactive, to ignoring. + +`isolate` targets: + - default + - rescue + - emergency + - halt + - poweroff + - reboot + - suspend + - hibernate + - hybrid-sleep + - suspend-then-hibernate + +`switch-root` + +## Service unit configuration + +https://www.freedesktop.org/software/systemd/man/systemd.service.html + +Service templates: can take a single argument to become instantiated. + +If a service unit config file doesn't exist, falls back to looking for +an init script and synthesizes a unit on the fly. + +Default dependencies: + - requires sysinit.target + - starts after sysinit.target + - starts after basic.target + - conflicts with shutdown.target + - shuts down before shutdown.target (?) + +"slice units"? Oh ok, hierarchical supervision... and configuration of +whole branches of the tree. + +Service lifecycle: + - states: active, activating, deactivating, dead, inactive, starting, ... more? + +Options: + + - Type (it's complicated) diff --git a/notes/init.md b/notes/init.md index b535a68..c29b9e9 100644 --- a/notes/init.md +++ b/notes/init.md @@ -77,3 +77,15 @@ and each service is aware of what it needs at the moment it starts. Services: are Syndicate programs that speak the protocol on stdio. To run other things, a supervisor program will listen to Syndicate and run a subprocess in an ad-hoc way. + +# pid-1 concerns + +PID-1 concerns: + - sessions https://man7.org/linux/man-pages/man2/setsid.2.html + - handling of SIGINT and SIGTERM is special + - (and how should SIGSTOP / SIGTSTP/SIGTTIN/SIGTTOU work?? there's + some detail here https://github.com/Yelp/dumb-init I don't + understand) + - the container case is different from the host case + - "pivoting" to shutdown mode + - reaping of orphaned processes diff --git a/notes/logging.md b/notes/logging.md new file mode 100644 index 0000000..f0a752d --- /dev/null +++ b/notes/logging.md @@ -0,0 +1,18 @@ +--- +--- + +from `ioctl_tty(2)`: + + Redirecting console output + TIOCCONS + Argument: void + + Redirect output that would have gone to /dev/console or + /dev/tty0 to the given terminal. If that was a + pseudoterminal master, send it to the slave. In Linux + before version 2.6.10, anybody can do this as long as the + output was not redirected yet; since version 2.6.10, only + a process with the CAP_SYS_ADMIN capability may do this. + If output was redirected already, then EBUSY is returned, + but redirection can be stopped by using this ioctl with fd + pointing at /dev/console or /dev/tty0. diff --git a/notes/process-supervision.md b/notes/process-supervision.md index 310bfb9..79cf6a0 100644 --- a/notes/process-supervision.md +++ b/notes/process-supervision.md @@ -105,3 +105,12 @@ Logging in daemontools: - stdout is piped to stdin of the logger program runit - see https://docs.voidlinux.org/config/services/index.html + +2021-08-24 I asked on IRC: "I have a question about Erlang history, I +wonder if any of the old timers are here. I want to know how and when +supervisor.erl began its life. Joe's HOPL paper mentions "BOS" as a +source of inspiration, but I want to know more..." + +> 15:03:25 < okeuday> tonyg: OTP behaviors were attributed to Lennart +> Öhman (working at Sjöland & Thyselius Telecom AB) in the past, but +> there are likely more details involved