On Tue, Jan 14, 2025 at 09:54:36PM +0000, Andrew Bower wrote: > On Tue, Jan 14, 2025 at 06:14:02PM +0000, Andrew Bower wrote: > Please find attached a patch to implement startup synchronisation with > python3-sdnotify.
Sorry, really attached this time.
>From 7ed1e6270d7577aab210043ec7eb520004fd7bf2 Mon Sep 17 00:00:00 2001 From: Andrew Bower <and...@bower.uk> Date: Tue, 14 Jan 2025 18:41:35 +0000 Subject: [PATCH] Use sd_notify method to sync listener with supervisory process d/control: add dependency on python3-sdnotify (Closes: #1093029) --- debian/control | 3 +- ...KET-to-sync-with-supervisory-process.patch | 58 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 debian/patches/0003-Use-NOTIFY_SOCKET-to-sync-with-supervisory-process.patch create mode 100644 debian/patches/series diff --git a/debian/control b/debian/control index ba7e9b2..ac5ea77 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,8 @@ Section: web Priority: optional Maintainer: Keith Packard <kei...@keithp.com> Build-Depends: debhelper-compat (= 13), dh-python, python3, python3-setuptools, python3-vobject, - python3-daemon, python3-lockfile, python3-iniparse, git + python3-daemon, python3-lockfile, python3-iniparse, git, + python3-sdnotify, Standards-Version: 4.5.1 Rules-Requires-Root: no Homepage: https://keithp.com/calypso diff --git a/debian/patches/0003-Use-NOTIFY_SOCKET-to-sync-with-supervisory-process.patch b/debian/patches/0003-Use-NOTIFY_SOCKET-to-sync-with-supervisory-process.patch new file mode 100644 index 0000000..b4798d8 --- /dev/null +++ b/debian/patches/0003-Use-NOTIFY_SOCKET-to-sync-with-supervisory-process.patch @@ -0,0 +1,58 @@ +From: Andrew Bower <and...@bower.uk> +Date: Tue, 14 Jan 2025 18:00:00 +0000 +Forwarded: no +Subject: Use NOTIFY_SOCKET to sync with supervisory process + +--- + calypso.py | 8 ++++++++ + requirements.txt | 1 + + setup.py | 2 +- + 3 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/calypso.py b/calypso.py +index 3315d0d..48ea24d 100755 +--- a/calypso.py ++++ b/calypso.py +@@ -38,6 +38,7 @@ arguments. + + import daemon + import lockfile ++import sdnotify + import logging + import optparse + import os +@@ -134,6 +135,13 @@ def run_server(): + server_class = calypso.HTTPSServer if options.ssl else calypso.HTTPServer + server = server_class( + (options.host, options.port), calypso.CollectionHTTPHandler) ++ ++ # Now the listener is started, synchronize with any supervisory ++ # process. This will do nothing if no one is waiting on us. ++ supervisor = sdnotify.SystemdNotifier() ++ supervisor.notify("READY=1") ++ ++ # Enter service loop + server.serve_forever(poll_interval=10) + except KeyboardInterrupt: + server.socket.close() +diff --git a/requirements.txt b/requirements.txt +index d51c681..820af6a 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -1,2 +1,3 @@ + python3-daemon>=2.1.1 + python3-vobject>=0.9.6.1 ++python3-sdnotify +diff --git a/setup.py b/setup.py +index b8a0658..5e455b1 100755 +--- a/setup.py ++++ b/setup.py +@@ -77,7 +77,7 @@ setup( + platforms="Any", + packages=["calypso", "calypso.acl"], + provides=["calypso"], +- install_requires=["daemon","vobject"], ++ install_requires=["daemon","vobject","sdnotify"], + tests_require=['nose>=0.11.1'], + scripts=["calypso.py"], + cmdclass={"build_scripts": BuildScripts}, diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..0c82791 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +0003-Use-NOTIFY_SOCKET-to-sync-with-supervisory-process.patch -- 2.45.2