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.
This commit is contained in:
Dragory 2023-06-26 19:35:19 +00:00
parent 1734ba4ac9
commit 29a1161c05
No known key found for this signature in database
3 changed files with 6 additions and 28 deletions

View file

@ -58,7 +58,8 @@ services:
- ./:/zeppelin - ./:/zeppelin
environment: environment:
DEBUG: ${DEBUG-} DEBUG: ${DEBUG-}
command: ["/bin/bash", "/zeppelin/docker/production/start-api.sh"] working_dir: /zeppelin/backend
command: ["npm", "run", "start-api-prod"]
bot: bot:
build: build:

View file

@ -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

View file

@ -1,17 +1,12 @@
#!/bin/bash #!/bin/bash
# This wrapper script is used for two purposes: # This wrapper script is used to run different things based on the DEBUG env variable
# 1. Waiting for the prepare_backend container to finish before starting (see https://github.com/docker/compose/issues/5007#issuecomment-335815508) # Exec is used to forward signals: https://unix.stackexchange.com/a/196053
# 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;
cd /zeppelin/backend cd /zeppelin/backend
if [ -n "$DEBUG" ]; then if [ -n "$DEBUG" ]; then
echo "Starting bot in debug mode" echo "DEBUG MODE: Starting bot container without starting the bot"
exec env NO_INSIGHT=true npm run start-bot-prod-debug exec tail -f /dev/null
else else
echo "Starting bot" echo "Starting bot"
exec npm run start-bot-prod exec npm run start-bot-prod