Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/19116.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move exception handling up the stack (avoid `exit(1)` in our composable functions).
16 changes: 8 additions & 8 deletions synapse/app/generic_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,11 @@ def start(config: HomeServerConfig) -> None:
# Start the tracer
init_tracer(hs) # noqa

try:
hs.setup()
hs.setup()

# Ensure the replication streamer is always started in case we write to any
# streams. Will no-op if no streams can be written to by this worker.
hs.get_replication_streamer()
except Exception as e:
handle_startup_exception(e)
# Ensure the replication streamer is always started in case we write to any
# streams. Will no-op if no streams can be written to by this worker.
hs.get_replication_streamer()

async def start() -> None:
await _base.start(hs)
Expand All @@ -388,7 +385,10 @@ async def start() -> None:
def main() -> None:
homeserver_config = load_config(sys.argv[1:])
with LoggingContext(name="main", server_name=homeserver_config.server.server_name):
start(homeserver_config)
try:
start(homeserver_config)
except Exception as e:
handle_startup_exception(e)


if __name__ == "__main__":
Expand Down
10 changes: 5 additions & 5 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,7 @@ def setup(
# Start the tracer
init_tracer(hs) # noqa

try:
hs.setup()
except Exception as e:
handle_startup_exception(e)
hs.setup()

async def _start_when_reactor_running() -> None:
# TODO: Feels like this should be moved somewhere else.
Expand Down Expand Up @@ -464,7 +461,10 @@ def main() -> None:
# check base requirements
check_requirements()
hs = create_homeserver(homeserver_config)
setup(hs)
try:
setup(hs)
except Exception as e:
handle_startup_exception(e)

# redirect stdio to the logs, if configured.
if not hs.config.logging.no_redirect_stdio:
Expand Down