From c812b4d3f7c8276fbf9ceb13ae01da4fb5afae01 Mon Sep 17 00:00:00 2001 From: fumoboy007 <2100868+fumoboy007@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:43:49 -0700 Subject: [PATCH] Disable Python buffering of standard output/error streams. The code uses `print` to log messages, so disable buffering to output the messages as soon as they are written. Fixes #437. --- Dockerfile | 4 ++++ Dockerfile.metadata_service | 7 ++++++- Dockerfile.migration_service | 7 ++++++- Dockerfile.ui_service | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index bce8be6a..c4e1b942 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,5 +46,9 @@ RUN /root/services/ui_backend_service/download_ui.sh ADD services/migration_service /root/services/migration_service RUN pip3 install -r /root/services/migration_service/requirements.txt +# The program uses `print` to log messages, so disable buffering to output the messages as soon as +# they are written. +ENV PYTHONUNBUFFERED=1 + RUN chmod 777 /root/services/migration_service/run_script.py CMD python3 services/migration_service/run_script.py diff --git a/Dockerfile.metadata_service b/Dockerfile.metadata_service index 8406c36d..be0a6ac7 100644 --- a/Dockerfile.metadata_service +++ b/Dockerfile.metadata_service @@ -10,4 +10,9 @@ ADD services/metadata_service /root/services/metadata_service ADD setup.py setup.cfg /root/ WORKDIR /root RUN pip install --editable . -CMD metadata_service \ No newline at end of file + +# The program uses `print` to log messages, so disable buffering to output the messages as soon as +# they are written. +ENV PYTHONUNBUFFERED=1 + +CMD metadata_service diff --git a/Dockerfile.migration_service b/Dockerfile.migration_service index 948d4fe4..208946e4 100644 --- a/Dockerfile.migration_service +++ b/Dockerfile.migration_service @@ -13,4 +13,9 @@ ADD services/migration_service /root/services/migration_service ADD setup.py setup.cfg run_goose.py /root/ WORKDIR /root RUN pip install --editable . -CMD migration_service \ No newline at end of file + +# The program uses `print` to log messages, so disable buffering to output the messages as soon as +# they are written. +ENV PYTHONUNBUFFERED=1 + +CMD migration_service diff --git a/Dockerfile.ui_service b/Dockerfile.ui_service index 3a78898c..0164268d 100644 --- a/Dockerfile.ui_service +++ b/Dockerfile.ui_service @@ -32,4 +32,8 @@ RUN /root/services/ui_backend_service/download_ui.sh RUN pip install --editable . +# The program uses `print` to log messages, so disable buffering to output the messages as soon as +# they are written. +ENV PYTHONUNBUFFERED=1 + CMD ui_backend_service