From 6d86df73f18803c148c320c3b3089cb0d7e2f30a Mon Sep 17 00:00:00 2001 From: Chris Moos Date: Thu, 15 Aug 2019 18:16:27 -0700 Subject: Fix issue with Synapse not starting up. Fixes #5866. Signed-off-by: Chris Moos --- synapse/app/homeserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'synapse') diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 7d6b51b5bc..8233905844 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -447,7 +447,7 @@ def setup(config_options): reactor.stop() sys.exit(1) - reactor.addSystemEventTrigger("before", "startup", start) + reactor.callWhenRunning(start) return hs -- cgit 1.4.1 From 412c6e21a8d564706b67b99fd6399242707c40ea Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Sat, 17 Aug 2019 09:09:52 +0100 Subject: Drop dependency on sdnotify (#5871) ... to save OSes which don't use it from having to maintain a port. Fixes #5865. --- changelog.d/5871.feature | 1 + synapse/app/_base.py | 47 +++++++++++++++++++++++++++++++++--------- synapse/python_dependencies.py | 1 - 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 changelog.d/5871.feature (limited to 'synapse') diff --git a/changelog.d/5871.feature b/changelog.d/5871.feature new file mode 100644 index 0000000000..8805607bf1 --- /dev/null +++ b/changelog.d/5871.feature @@ -0,0 +1 @@ +Drop hard dependency on `sdnotify` python package. \ No newline at end of file diff --git a/synapse/app/_base.py b/synapse/app/_base.py index c010e70955..69dcf3523f 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -17,10 +17,10 @@ import gc import logging import os import signal +import socket import sys import traceback -import sdnotify from daemonize import Daemonize from twisted.internet import defer, error, reactor @@ -246,13 +246,12 @@ def start(hs, listeners=None): def handle_sighup(*args, **kwargs): # Tell systemd our state, if we're using it. This will silently fail if # we're not using systemd. - sd_channel = sdnotify.SystemdNotifier() - sd_channel.notify("RELOADING=1") + sdnotify(b"RELOADING=1") for i in _sighup_callbacks: i(hs) - sd_channel.notify("READY=1") + sdnotify(b"READY=1") signal.signal(signal.SIGHUP, handle_sighup) @@ -308,16 +307,12 @@ def setup_sdnotify(hs): # Tell systemd our state, if we're using it. This will silently fail if # we're not using systemd. - sd_channel = sdnotify.SystemdNotifier() - hs.get_reactor().addSystemEventTrigger( - "after", - "startup", - lambda: sd_channel.notify("READY=1\nMAINPID=%s" % (os.getpid())), + "after", "startup", sdnotify, b"READY=1\nMAINPID=%i" % (os.getpid(),) ) hs.get_reactor().addSystemEventTrigger( - "before", "shutdown", lambda: sd_channel.notify("STOPPING=1") + "before", "shutdown", sdnotify, b"STOPPING=1" ) @@ -414,3 +409,35 @@ class _DeferredResolutionReceiver(object): def resolutionComplete(self): self._deferred.callback(()) self._receiver.resolutionComplete() + + +sdnotify_sockaddr = os.getenv("NOTIFY_SOCKET") + + +def sdnotify(state): + """ + Send a notification to systemd, if the NOTIFY_SOCKET env var is set. + + This function is based on the sdnotify python package, but since it's only a few + lines of code, it's easier to duplicate it here than to add a dependency on a + package which many OSes don't include as a matter of principle. + + Args: + state (bytes): notification to send + """ + if not isinstance(state, bytes): + raise TypeError("sdnotify should be called with a bytes") + if not sdnotify_sockaddr: + return + addr = sdnotify_sockaddr + if addr[0] == "@": + addr = "\0" + addr[1:] + + try: + with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as sock: + sock.connect(addr) + sock.sendall(state) + except Exception as e: + # this is a bit surprising, since we don't expect to have a NOTIFY_SOCKET + # unless systemd is expecting us to notify it. + logger.warning("Unable to send notification to systemd: %s", e) diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 195a7a70c8..c6465c0386 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -72,7 +72,6 @@ REQUIREMENTS = [ "netaddr>=0.7.18", "Jinja2>=2.9", "bleach>=1.4.3", - "sdnotify>=0.3", ] CONDITIONAL_REQUIREMENTS = { -- cgit 1.4.1 From 74fb72921352a6aaa3736c9b45a9d0e3cdfe0d21 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Sat, 17 Aug 2019 09:16:17 +0100 Subject: 1.3.1 --- CHANGES.md | 15 +++++++++++++++ changelog.d/5867.bugfix | 1 - changelog.d/5871.feature | 1 - debian/changelog | 14 ++++++++++++-- synapse/__init__.py | 2 +- 5 files changed, 28 insertions(+), 5 deletions(-) delete mode 100644 changelog.d/5867.bugfix delete mode 100644 changelog.d/5871.feature (limited to 'synapse') diff --git a/CHANGES.md b/CHANGES.md index d13dcb717e..f25c7d0c1a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,18 @@ +Synapse 1.3.1 (2019-08-17) +========================== + +Features +-------- + +- Drop hard dependency on `sdnotify` python package. ([\#5871](https://github.com/matrix-org/synapse/issues/5871)) + + +Bugfixes +-------- + +- Fix startup issue (hang on ACME provisioning) due to ordering of Twisted reactor startup. Thanks to @chrismoos for supplying the fix. ([\#5867](https://github.com/matrix-org/synapse/issues/5867)) + + Synapse 1.3.0 (2019-08-15) ========================== diff --git a/changelog.d/5867.bugfix b/changelog.d/5867.bugfix deleted file mode 100644 index d68b152762..0000000000 --- a/changelog.d/5867.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix startup issue (hang on ACME provisioning) due to ordering of Twisted reactor startup. Thanks to @chrismoos for supplying the fix. \ No newline at end of file diff --git a/changelog.d/5871.feature b/changelog.d/5871.feature deleted file mode 100644 index 8805607bf1..0000000000 --- a/changelog.d/5871.feature +++ /dev/null @@ -1 +0,0 @@ -Drop hard dependency on `sdnotify` python package. \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 83232a0bad..76efc442d7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,19 @@ +matrix-synapse-py3 (1.3.1) stable; urgency=medium + + * New synapse release 1.3.1. + + -- Synapse Packaging team Sat, 17 Aug 2019 09:15:49 +0100 + matrix-synapse-py3 (1.3.0) stable; urgency=medium [ Andrew Morgan ] * Remove libsqlite3-dev from required build dependencies. + [ Synapse Packaging team ] + * New synapse release 1.3.0. + + -- Synapse Packaging team Thu, 15 Aug 2019 12:04:23 +0100 + matrix-synapse-py3 (1.2.0) stable; urgency=medium [ Amber Brown ] @@ -13,9 +24,8 @@ matrix-synapse-py3 (1.2.0) stable; urgency=medium [ Synapse Packaging team ] * New synapse release 1.2.0. - * New synapse release 1.3.0. - -- Synapse Packaging team Thu, 15 Aug 2019 12:04:23 +0100 + -- Synapse Packaging team Thu, 25 Jul 2019 14:10:07 +0100 matrix-synapse-py3 (1.1.0) stable; urgency=medium diff --git a/synapse/__init__.py b/synapse/__init__.py index 02ae90b072..6766ef445c 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -35,4 +35,4 @@ try: except ImportError: pass -__version__ = "1.3.0" +__version__ = "1.3.1" -- cgit 1.4.1