matrix-synapse: also expose synapse.app.generic_worker via setup.py

This commit is contained in:
Maximilian Bosch 2021-10-08 14:46:09 +02:00
parent b0ab15b0a1
commit b44e0ef9ce
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E
3 changed files with 45 additions and 1 deletions

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 ];