Skip to content

Commit

Permalink
Revert "Squash #2041 - Update Health Check to search for PID under dd…
Browse files Browse the repository at this point in the history
…-trace"

This reverts commit 2f63640.
  • Loading branch information
MackHalliday committed Nov 21, 2024
1 parent 2f63640 commit 7295bf9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
13 changes: 1 addition & 12 deletions cd/application-deployment/dev/vaec-celery-task-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,7 @@
"sh",
"-c",
"/app/scripts/run_celery.sh"
],
"healthCheck": {
"command": [
"CMD",
"sh",
"-c",
"./scripts/check_celery.sh"
],
"interval": 30,
"retries": 5,
"timeout": 10
}
]
},
{
"name": "datadog-agent",
Expand Down
19 changes: 7 additions & 12 deletions scripts/check_celery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
set -e

function get_celery_pids {
# First, get the PID from the celery.pid file
MAIN_PID=$(cat /tmp/celery.pid)

# Check if the main process is ddtrace-run or Celery directly
if pstree -p ${MAIN_PID} | grep -q 'ddtrace'; then
# If ddtrace-run is present, navigate to the child process
APP_PIDS=$(pstree -p ${MAIN_PID} | sed 's/.*-ddtrace(\([0-9]*\)).*-celery(\([0-9]*\)).*/\2/')
else
# If no ddtrace-run, assume the main process is Celery
APP_PIDS=$(pstree -p ${MAIN_PID} | sed 's/.*-celery(\([0-9]*\)).*/\1/')
fi
# get the PIDs of the process whose parent is the main celery process, saved in celery.pid
# print only pid and their command, get the ones with "celery" in their name
# and keep only these PIDs

set +o pipefail # so grep returning no matches does not premature fail pipe
APP_PIDS=$(pstree -p `cat /tmp/celery.pid` | sed 's/\(.*\)-celery(\(\d*\))/\2/')
echo "Here are the APP_PIDS: ${APP_PIDS}"
set -o pipefail # pipefail should be set everywhere else
}

function ensure_celery_is_running {
Expand All @@ -25,7 +20,7 @@ function ensure_celery_is_running {
fi

for APP_PID in ${APP_PIDS}; do
kill -0 ${APP_PID} 2>/dev/null || return 1
kill -0 ${APP_PID} 2&>/dev/null || return 1
done
}

Expand Down

0 comments on commit 7295bf9

Please sign in to comment.