1
0

Move notify_appservices from worker type / config option to config option only

This commit is contained in:
Andrew Morgan
2021-08-16 17:02:25 +01:00
parent 0ace38b7b3
commit cbf0bbf0df
5 changed files with 26 additions and 20 deletions

View File

@@ -2766,6 +2766,11 @@ opentracing:
#
#run_background_tasks_on: worker1
# The worker that is used to notify application services of new traffic within
# their configured namespace. If not provided this defaults to the main process.
#
#notify_appservices_from_worker: worker2
# A shared secret used by the replication APIs to authenticate HTTP requests
# from workers.
#

View File

@@ -427,22 +427,6 @@ def start(config_options):
"synapse.app.user_dir",
)
if config.worker_app == "synapse.app.appservice":
if config.appservice.notify_appservices:
sys.stderr.write(
"\nThe appservices must be disabled in the main synapse process"
"\nbefore they can be run in a separate worker."
"\nPlease add ``notify_appservices: false`` to the main config"
"\n"
)
sys.exit(1)
# Force the appservice to start since they will be disabled in the main config
config.appservice.notify_appservices = True
else:
# For other worker types we force this to off.
config.appservice.notify_appservices = False
if config.worker_app == "synapse.app.user_dir":
if config.server.update_user_directory:
sys.stderr.write(

View File

@@ -32,7 +32,6 @@ class AppServiceConfig(Config):
def read_config(self, config, **kwargs):
self.app_service_config_files = config.get("app_service_config_files", [])
self.notify_appservices = config.get("notify_appservices", True)
self.track_appservice_user_ips = config.get("track_appservice_user_ips", False)
def generate_config_section(cls, **kwargs):

View File

@@ -275,13 +275,26 @@ class WorkerConfig(Config):
# be able to run on only a single instance (meaning that they don't
# depend on any in-memory state of a particular worker).
#
# No effort is made to ensure only a single instance of these tasks is
# running.
# No effort is made here to ensure only a single instance of these tasks
# are running.
background_tasks_instance = config.get("run_background_tasks_on") or "master"
self.run_background_tasks = (
self.worker_name is None and background_tasks_instance == "master"
) or self.worker_name == background_tasks_instance
# Whether this worker should notify appservices of traffic within their namespace.
#
# As a note for developers, this task is currently not shardable, and thus should
# only be handled by a single process.
#
# No effort is made here to ensure only a single instance of this task running.
notify_appservices_instance = (
config.get("notify_appservices_from_worker") or "master"
)
self.should_notify_appservices = (
self.worker_name is None and notify_appservices_instance == "master"
) or self.worker_name == notify_appservices_instance
def generate_config_section(self, config_dir_path, server_name, **kwargs):
return """\
## Workers ##
@@ -323,6 +336,11 @@ class WorkerConfig(Config):
#
#run_background_tasks_on: worker1
# The worker that is used to notify application services of new traffic within
# their configured namespace. If not provided this defaults to the main process.
#
#notify_appservices_from_worker: worker2
# A shared secret used by the replication APIs to authenticate HTTP requests
# from workers.
#

View File

@@ -52,7 +52,7 @@ class ApplicationServicesHandler:
self.scheduler = hs.get_application_service_scheduler()
self.started_scheduler = False
self.clock = hs.get_clock()
self.notify_appservices = hs.config.notify_appservices
self.notify_appservices = hs.config.worker.should_notify_appservices
self.event_sources = hs.get_event_sources()
self.current_max = 0