diff options
author | realtyem <realtyem@gmail.com> | 2022-10-18 06:56:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 11:56:20 +0000 |
commit | 6c5082f3e08d1748d35eb709f6f5a9f30f17b8ff (patch) | |
tree | ad9d81755f177b80beb3ba019eb2c0333b6aa86f /docker/configure_workers_and_start.py | |
parent | When restarting a partial join resync, prioritise the server which actioned a... (diff) | |
download | synapse-6c5082f3e08d1748d35eb709f6f5a9f30f17b8ff.tar.xz |
Flush stdout/err in Dockerfile-workers before replacing the current process (#14195)
Also update `subprocess.check_output` to the slightly newer `subprocess.run`. Signed-off-by: Jason Little <realtyem@gmail.com>
Diffstat (limited to 'docker/configure_workers_and_start.py')
-rwxr-xr-x | docker/configure_workers_and_start.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index 60a5c10ea7..1ea456b2f8 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -230,24 +230,19 @@ upstream {upstream_worker_type} {{ # Utility functions def log(txt: str) -> None: - """Log something to the stdout. - - Args: - txt: The text to log. - """ print(txt) def error(txt: str) -> NoReturn: - """Log something and exit with an error code. - - Args: - txt: The text to log in error. - """ - log(txt) + print(txt, file=sys.stderr) sys.exit(2) +def flush_buffers() -> None: + sys.stdout.flush() + sys.stderr.flush() + + def convert(src: str, dst: str, **template_vars: object) -> None: """Generate a file from a template @@ -328,7 +323,7 @@ def generate_base_homeserver_config() -> None: # start.py already does this for us, so just call that. # note that this script is copied in in the official, monolith dockerfile os.environ["SYNAPSE_HTTP_PORT"] = str(MAIN_PROCESS_HTTP_LISTENER_PORT) - subprocess.check_output(["/usr/local/bin/python", "/start.py", "migrate_config"]) + subprocess.run(["/usr/local/bin/python", "/start.py", "migrate_config"], check=True) def generate_worker_files( @@ -642,6 +637,7 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None: # Start supervisord, which will start Synapse, all of the configured worker # processes, redis, nginx etc. according to the config we created above. log("Starting supervisord") + flush_buffers() os.execle( "/usr/local/bin/supervisord", "supervisord", |