Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Aug 17, 2019
2 parents 8a5f6ed + 74fb729 commit bdd201e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 15 deletions.
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
==========================

Expand Down
14 changes: 12 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
matrix-synapse-py3 (1.3.1) stable; urgency=medium

* New synapse release 1.3.1.

-- Synapse Packaging team <packages@matrix.org> 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 <packages@matrix.org> Thu, 15 Aug 2019 12:04:23 +0100

matrix-synapse-py3 (1.2.0) stable; urgency=medium

[ Amber Brown ]
Expand All @@ -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 <packages@matrix.org> Thu, 15 Aug 2019 12:04:23 +0100
-- Synapse Packaging team <packages@matrix.org> Thu, 25 Jul 2019 14:10:07 +0100

matrix-synapse-py3 (1.1.0) stable; urgency=medium

Expand Down
2 changes: 1 addition & 1 deletion synapse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
except ImportError:
pass

__version__ = "1.3.0"
__version__ = "1.3.1"
47 changes: 37 additions & 10 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"
)


Expand Down Expand Up @@ -414,3 +409,35 @@ def addressResolved(self, address):
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)
2 changes: 1 addition & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def start():
reactor.stop()
sys.exit(1)

reactor.addSystemEventTrigger("before", "startup", start)
reactor.callWhenRunning(start)

return hs

Expand Down
1 change: 0 additions & 1 deletion synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"netaddr>=0.7.18",
"Jinja2>=2.9",
"bleach>=1.4.3",
"sdnotify>=0.3",
]

CONDITIONAL_REQUIREMENTS = {
Expand Down

0 comments on commit bdd201e

Please sign in to comment.