From 29a1161c052989c0719428ec7baabd70bd5a250a Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:35:19 +0000 Subject: [PATCH] refactor: change how DEBUG behaves in prod The env var now only affects the bot container, not the API. This is because we don't currently need this extra debug information for the API. For the bot, with DEBUG set, the bot container will now start and do nothing. To start the bot in this container in debug mode, open a shell into the container and run the start-bot-prod-debug script manually. This change was made to allow more control over what profiling scripts and other things are run in the debug environment. --- docker-compose.production.yml | 3 ++- docker/production/start-api.sh | 18 ------------------ docker/production/start-bot.sh | 13 ++++--------- 3 files changed, 6 insertions(+), 28 deletions(-) delete mode 100755 docker/production/start-api.sh diff --git a/docker-compose.production.yml b/docker-compose.production.yml index 404158cb..1abcda66 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -58,7 +58,8 @@ services: - ./:/zeppelin environment: DEBUG: ${DEBUG-} - command: ["/bin/bash", "/zeppelin/docker/production/start-api.sh"] + working_dir: /zeppelin/backend + command: ["npm", "run", "start-api-prod"] bot: build: diff --git a/docker/production/start-api.sh b/docker/production/start-api.sh deleted file mode 100755 index b92ee6b7..00000000 --- a/docker/production/start-api.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# This wrapper script is used for two purposes: -# 1. Waiting for the prepare_backend container to finish before starting (see https://github.com/docker/compose/issues/5007#issuecomment-335815508) -# 2. Forwarding signals to the app (see https://unix.stackexchange.com/a/196053) - -# Wait for the backend preparations to finish before continuing -echo "Waiting for prepare_backend to finish before starting the API..." -while ping -c1 prepare_backend &>/dev/null; do sleep 1; done; - -cd /zeppelin/backend -if [ -n "$DEBUG" ]; then - echo "Starting API in debug mode" - exec env NO_INSIGHT=true npm run start-api-prod-debug -else - echo "Starting API" - exec npm run start-api-prod -fi diff --git a/docker/production/start-bot.sh b/docker/production/start-bot.sh index f8b8bacc..37e34d11 100644 --- a/docker/production/start-bot.sh +++ b/docker/production/start-bot.sh @@ -1,17 +1,12 @@ #!/bin/bash -# This wrapper script is used for two purposes: -# 1. Waiting for the prepare_backend container to finish before starting (see https://github.com/docker/compose/issues/5007#issuecomment-335815508) -# 2. Forwarding signals to the app (see https://unix.stackexchange.com/a/196053) - -# Wait for the backend preparations to finish before continuing -echo "Waiting for prepare_backend to finish before starting the bot..." -while ping -c1 prepare_backend &>/dev/null; do sleep 1; done; +# This wrapper script is used to run different things based on the DEBUG env variable +# Exec is used to forward signals: https://unix.stackexchange.com/a/196053 cd /zeppelin/backend if [ -n "$DEBUG" ]; then - echo "Starting bot in debug mode" - exec env NO_INSIGHT=true npm run start-bot-prod-debug + echo "DEBUG MODE: Starting bot container without starting the bot" + exec tail -f /dev/null else echo "Starting bot" exec npm run start-bot-prod