From b44e0ef9ce7cfdb05cf22bf02da8438edc2d7595 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 8 Oct 2021 14:46:09 +0200 Subject: [PATCH] matrix-synapse: also expose `synapse.app.generic_worker` via `setup.py` --- ...tup-add-homeserver-as-console-script.patch | 2 +- ...generic-worker-as-binary-under-NixOS.patch | 43 +++++++++++++++++++ pkgs/servers/matrix-synapse/default.nix | 1 + 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 pkgs/servers/matrix-synapse/0002-Expose-generic-worker-as-binary-under-NixOS.patch diff --git a/pkgs/servers/matrix-synapse/0001-setup-add-homeserver-as-console-script.patch b/pkgs/servers/matrix-synapse/0001-setup-add-homeserver-as-console-script.patch index eb70d21ed5cb..2a83c5fcf6d9 100644 --- a/pkgs/servers/matrix-synapse/0001-setup-add-homeserver-as-console-script.patch +++ b/pkgs/servers/matrix-synapse/0001-setup-add-homeserver-as-console-script.patch @@ -1,7 +1,7 @@ From 36ffbb7ad2c535180cae473b470a43f9db4fbdcd Mon Sep 17 00:00:00 2001 From: Maximilian Bosch 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, diff --git a/pkgs/servers/matrix-synapse/0002-Expose-generic-worker-as-binary-under-NixOS.patch b/pkgs/servers/matrix-synapse/0002-Expose-generic-worker-as-binary-under-NixOS.patch new file mode 100644 index 000000000000..11dd53c9ad3e --- /dev/null +++ b/pkgs/servers/matrix-synapse/0002-Expose-generic-worker-as-binary-under-NixOS.patch @@ -0,0 +1,43 @@ +From 3089758015c64cc1e6788793c4fe40a0e1783457 Mon Sep 17 00:00:00 2001 +From: Maximilian Bosch +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 + diff --git a/pkgs/servers/matrix-synapse/default.nix b/pkgs/servers/matrix-synapse/default.nix index 1c5e92a94bb4..d0077a8c5cdc 100644 --- a/pkgs/servers/matrix-synapse/default.nix +++ b/pkgs/servers/matrix-synapse/default.nix @@ -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 ];