Merge pull request #140979 from Ma27/matrix-workers

nixos/matrix-synapse: minor improvements to implement worker-support
This commit is contained in:
Maximilian Bosch 2021-10-09 15:24:41 +02:00 committed by GitHub
commit cbfe4a42f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 1 deletions

View File

@ -122,6 +122,14 @@ in {
options = {
services.matrix-synapse = {
enable = mkEnableOption "matrix.org synapse";
configFile = mkOption {
type = types.str;
readOnly = true;
description = ''
Path to the configuration file on the target system. Useful to configure e.g. workers
that also need this.
'';
};
package = mkOption {
type = types.package;
default = pkgs.matrix-synapse;
@ -706,6 +714,8 @@ in {
}
];
services.matrix-synapse.configFile = "${configFile}";
users.users.matrix-synapse = {
group = "matrix-synapse";
home = cfg.dataDir;

View File

@ -1,7 +1,7 @@
From 36ffbb7ad2c535180cae473b470a43f9db4fbdcd Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Mon, 16 Aug 2021 13:27:28 +0200
Subject: [PATCH] setup: add homeserver as console script
Subject: [PATCH 1/2] setup: add homeserver as console script
With this change, it will be added to `$out/bin` in `nixpkgs` directly.
This became necessary since our old workaround, calling it as script,

View File

@ -0,0 +1,43 @@
From 3089758015c64cc1e6788793c4fe40a0e1783457 Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Tue, 5 Oct 2021 22:33:12 +0200
Subject: [PATCH 2/2] Expose generic worker as binary under NixOS
---
setup.py | 3 ++-
synapse/app/generic_worker.py | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 27f1d842c..6383aed6f 100755
--- a/setup.py
+++ b/setup.py
@@ -135,7 +135,8 @@ setup(
python_requires="~=3.6",
entry_points={
'console_scripts': [
- 'homeserver = synapse.app.homeserver:main'
+ 'homeserver = synapse.app.homeserver:main',
+ 'worker = synapse.app.generic_worker:main'
]
},
classifiers=[
diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py
index 3b7131af8..c77a6a95c 100644
--- a/synapse/app/generic_worker.py
+++ b/synapse/app/generic_worker.py
@@ -491,6 +491,10 @@ def start(config_options):
_base.start_worker_reactor("synapse-generic-worker", config)
-if __name__ == "__main__":
+def main():
with LoggingContext("main"):
start(sys.argv[1:])
+
+
+if __name__ == "__main__":
+ main()
--
2.31.1

View File

@ -36,6 +36,7 @@ buildPythonApplication rec {
patches = [
./0001-setup-add-homeserver-as-console-script.patch
./0002-Expose-generic-worker-as-binary-under-NixOS.patch
];
buildInputs = [ openssl ];