From 2977bb3ae5d79afcf08c6707bb40b2882bbe9dfa Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Mon, 16 Aug 2021 13:27:28 +0200 Subject: [PATCH 1/5] 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, doesn't work anymore since the shebangs were removed[1]. [1] https://github.com/matrix-org/synapse/pull/10415 Signed-off-by: Maximilian Bosch --- setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.py b/setup.py index ad99b3bd2c73..662d204ce8ed 100755 --- a/setup.py +++ b/setup.py @@ -152,6 +152,11 @@ def exec_file(path_segments): long_description=long_description, long_description_content_type="text/x-rst", python_requires="~=3.6", + entry_points={ + 'console_scripts': [ + 'homeserver = synapse.app.homeserver:main' + ] + }, classifiers=[ "Development Status :: 5 - Production/Stable", "Topic :: Communications :: Chat", From 58e87d50abfca2031e5ddf05c66f9c151655e44f Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 5 Oct 2021 22:33:12 +0200 Subject: [PATCH 2/5] Expose generic worker as executable Signed-off-by: Maximilian Bosch --- 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 662d204ce8ed..05e07bd4e52a 100755 --- a/setup.py +++ b/setup.py @@ -154,7 +154,8 @@ def exec_file(path_segments): 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 b4bed5bf40b9..bb671e01ffb4 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -505,6 +505,10 @@ def start(config_options: List[str]) -> None: _base.start_worker_reactor("synapse-generic-worker", config) -if __name__ == "__main__": +def main(): with LoggingContext("main"): start(sys.argv[1:]) + + +if __name__ == "__main__": + main() From 232c2bf08c70f485472766c07b20e9c1aed2e302 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 30 Nov 2021 14:53:22 +0100 Subject: [PATCH 3/5] Review fixes * add changelog entry * rename entry_points * satisfy linter Signed-off-by: Maximilian Bosch --- changelog.d/11449.feature | 1 + setup.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog.d/11449.feature diff --git a/changelog.d/11449.feature b/changelog.d/11449.feature new file mode 100644 index 000000000000..3df2a50b0663 --- /dev/null +++ b/changelog.d/11449.feature @@ -0,0 +1 @@ +'Expose synapse_homeserver and synapse_worker commands as entry points to run Synapse's main process and worker processes, respectively. Contributed by @Ma27.' diff --git a/setup.py b/setup.py index 05e07bd4e52a..8a95e71c5777 100755 --- a/setup.py +++ b/setup.py @@ -153,9 +153,9 @@ def exec_file(path_segments): long_description_content_type="text/x-rst", python_requires="~=3.6", entry_points={ - 'console_scripts': [ - 'homeserver = synapse.app.homeserver:main', - 'worker = synapse.app.generic_worker:main' + "console_scripts": [ + "synapse_homeserver = synapse.app.homeserver:main", + "synapse_worker = synapse.app.generic_worker:main" ] }, classifiers=[ From 01aade9d95a2839bae5c3b9ba77968d717462d47 Mon Sep 17 00:00:00 2001 From: reivilibre Date: Tue, 30 Nov 2021 14:27:32 +0000 Subject: [PATCH 4/5] Fixup newsfile --- changelog.d/11449.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/11449.feature b/changelog.d/11449.feature index 3df2a50b0663..94bc175db995 100644 --- a/changelog.d/11449.feature +++ b/changelog.d/11449.feature @@ -1 +1 @@ -'Expose synapse_homeserver and synapse_worker commands as entry points to run Synapse's main process and worker processes, respectively. Contributed by @Ma27.' +Expose synapse_homeserver and synapse_worker commands as entry points to run Synapse's main process and worker processes, respectively. Contributed by @Ma27. From 6ea90ba20e98a9c3f90cf3ad2eebe44d6bbe9e28 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 30 Nov 2021 16:20:55 +0000 Subject: [PATCH 5/5] Satisfy the code style and typing requirements --- setup.py | 2 +- synapse/app/generic_worker.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8a95e71c5777..2c6fb9aacb45 100755 --- a/setup.py +++ b/setup.py @@ -155,7 +155,7 @@ def exec_file(path_segments): entry_points={ "console_scripts": [ "synapse_homeserver = synapse.app.homeserver:main", - "synapse_worker = synapse.app.generic_worker:main" + "synapse_worker = synapse.app.generic_worker:main", ] }, classifiers=[ diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py index bb671e01ffb4..e256de200355 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -505,7 +505,7 @@ def start(config_options: List[str]) -> None: _base.start_worker_reactor("synapse-generic-worker", config) -def main(): +def main() -> None: with LoggingContext("main"): start(sys.argv[1:])