Skip to content

Commit

Permalink
Properly wait for agent startup
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah-witt committed Dec 5, 2022
1 parent 489fb55 commit be3f0ea
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions lib/scripts/update_agent_config.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
#!/bin/sh

# wait for the buildpack scripts to finish
timeout=0
while { ! [ "$(pgrep -f ./agent)" = "" ] && ! [ "$(pgrep -f ./dogstatsd)" = "" ]; } && [ $timeout -lt 120 ]; do
sleep 1
timeout=$((timeout+1))
done
DEBUG_FILE="/home/vcap/app/.datadog/update_agent_config_out.log"

# for debugging purposes
echo $DD_NODE_AGENT_TAGS >> /home/vcap/app/.datadog/dd-node-agent-tags.log
main() {
echo "Starting to wait for agent process to start"
timeout=0

while [ $timeout -lt 120 ]; do
echo "Waiting for agent process to start"

if pgrep -f ./agent; then
echo "Found agent process"
break
fi

/bin/bash /home/vcap/app/.datadog/scripts/update_agent_config_restart.sh
if pgrep -f ./dogstatsd; then
echo "Found dogstatsd process"
break
fi
sleep 1
timeout=$((timeout+1))
done
echo "$DD_NODE_AGENT_TAGS"

/bin/bash /home/vcap/app/.datadog/scripts/update_agent_config_restart.sh
}
# for debugging purposes
main "$@" >> "$DEBUG_FILE" 2>&1

0 comments on commit be3f0ea

Please sign in to comment.