Re: sdnotify-wrapper but the other way around
Jan Braun <[email protected]> Tue, 4 Mar 2025 01:36:25 +0100
| Newsgroups | gmane.comp.sysutils.supervision.general |
|---|---|
| Message-ID | <Z8ZLCWGSG9QVSTd1@abakus> |
Hi, [email protected] schrob: > On Sun, Mar 2, 2025, at 3:10 AM, Jan Braun wrote: > > just setting up the notification-fd. > > I'm not sure how to do this, since the sd-notify protocol[1] doesn't > inherit an fd; instead it looks at env var NOTIFY_SOCKET to read a > path to a unix socket, which the ready service opens and uses to send > datagrams. Dang, that's what I get for not testing things; I was misremembering that it was an inherited fd. Sorry :( > If there's a way to connect a unix datagram socket to the > notification-fd provided by s6 more directly than I've done here, I'd > love to know how! Not really. But I prefer doing things in shell when I can get away with it, so here's a ./run script to use with ./notification-fd 3: | #!/bin/sh | set -eu | | NOTIFY_SOCKET=`realpath ./notify` | export NOTIFY_SOCKET | timeout 1234 socat "unix-recvfrom:$NOTIFY_SOCKET,unlink-early" "system:paste >&3" & | | # fake service: | exec python3 -c "import systemd.daemon, time; systemd.daemon.notify('READY=1'); time.sleep(10)" The paste(1) is there to actually create the newline. While sd_notify(3) says "A trailing newline is implied if none is specified", python doesn't produce one. So much for cleverly reusing that. Yay. regards, Jan
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEFzbVDxcLcKaSI7wVKV5wPm0dL88FAmfGSwQACgkQKV5wPm0d L8/sZw/+PQFOVq9snkh+x4uzqAZfg+a2Gx4CgvqAPYvNTPZfPE5rZ6NX1ChvQzkc xg3J0pbW1Gpy/tp5bQz2lB5p+xWs5lWP3HrP4PfpR4IyqkO7fHnITrZxBpqvwYgd zpyNgKKAMMNXk7e7kX9MMNRIqFLFiekF3CzscpH2QH7SB5F6UJi3EGngIpfRbSCW Ese7ky6mTBHdR/+y+jVOBNhEo7n1lw4InEG3UO6f7Wy4UOKb1FyZ8xtYzk0anUdc srKDpVOu3spfLee57dgulI+89/7NLE10KZso0bOz50alWspU+wPBJXayj6jpUZtA JG0mZM90rohVB4fHSA/LufizmswgKMvq0EbDKoV022gIZIemeB9JIW29YZ49VcB4 1NPaMpz3nVi6GOW2ZTnBasYUYg1+UkPMsOEYW7cGXo1JP+7csOeBTYPmFymFS6lh mvY1FOGcVkC9HRDvpCsW3/cdwE33g0vLMTu/XQ6NJSQ5KW4qwAo8lWLRzKaI89eL STyYPxAd7xnuWevPECwAso3TdHhDo5iePxrvBMx5Yr5bLlzq3oLvt//zs9FLe7r/ F9a+EEbu3gZ+bqvR3QX2CA/9k7aqHQazgMEMtRoHLrZGC3fFda2+QgzoihG5y2gx U7dz8/VGqRe86I5kMxY9evJyt41BnEXAw6iOy2axszYf3x9ILoQ= =Iig9 -----END PGP SIGNATURE-----