mirror of
https://github.com/9001/copyparty.git
synced 2026-06-18 20:22:27 -06:00
s6-notify: support fd-based s6 notification protocol (#1466)
Dinit and s6 supervision suite are known to support this protocol. See https://skarnet.org/software/s6/notifywhenup.html and https://davmac.org/projects/dinit/man-pages-html/dinit-service.5.html#ready Signed-off-by: Mobin Aydinfar <mobin@mobintestserver.ir>
This commit is contained in:
parent
b2401ff15a
commit
8c201b844e
|
|
@ -987,6 +987,10 @@ class SvcHub(object):
|
|||
|
||||
Daemon(self.sd_notify, "sd-notify")
|
||||
|
||||
zb = os.environ.get("S6_NOTIFY_FD")
|
||||
if zb:
|
||||
Daemon(self.s6_notify, "s6-notify", (zb,))
|
||||
|
||||
def _feature_test(self) -> None:
|
||||
fok = []
|
||||
fng = []
|
||||
|
|
@ -1897,6 +1901,17 @@ class SvcHub(object):
|
|||
except:
|
||||
self.log("sd_notify", min_ex())
|
||||
|
||||
def s6_notify(self, zb: bytes) -> None:
|
||||
try:
|
||||
fd = int(zb)
|
||||
if fd < 3:
|
||||
raise Exception("value < 3")
|
||||
os.write(fd, b"\n")
|
||||
os.close(fd)
|
||||
except:
|
||||
t = "S6_NOTIFY_FD=%s:\n%s"
|
||||
self.log("s6-notify", t % (zb, min_ex()), 1)
|
||||
|
||||
def log_stacks(self) -> None:
|
||||
td = time.time() - self.tstack
|
||||
if td < 300:
|
||||
|
|
|
|||
Loading…
Reference in a new issue