-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wait for agent startup before updating CAPI tags (#145)
* Properly wait for agent startup * Wait for token as well * small refactor * Add back datadog dir when using as argument; harmonize compile and supply * Fix pid file name Co-authored-by: Noueman Khalikine <noueman.khalikine@datadoghq.com>
- Loading branch information
1 parent
bedf448
commit 9c20fd5
Showing
6 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2022-Present Datadog, Inc. | ||
|
||
DATADOG_DIR="${DATADOG_DIR:-/home/vcap/app/.datadog}" | ||
|
||
check_datadog() { | ||
while true; do | ||
echo "Waiting for agent or dogstatsd process to start" | ||
if [ -f "${DATADOG_DIR}/run/agent.pid" ]; then | ||
echo "Found agent process" | ||
if [ -f "${DATADOG_DIR}/dist/auth_token" ]; then | ||
echo "Found agent token" | ||
break | ||
else | ||
echo "Agent token not found" | ||
fi | ||
fi | ||
|
||
if [ -f "${DATADOG_DIR}/run/dogstatsd.pid" ]; then | ||
echo "Found dogstatsd process" | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
} | ||
|
||
main() { | ||
check_datadog | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
#!/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 | ||
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2022-Present Datadog, Inc. | ||
|
||
# for debugging purposes | ||
echo $DD_NODE_AGENT_TAGS >> /home/vcap/app/.datadog/dd-node-agent-tags.log | ||
DATADOG_DIR="${DATADOG_DIR:-/home/vcap/app/.datadog}" | ||
DEBUG_FILE="${DATADOG_DIR}/update_agent_config_out.log" | ||
|
||
main() { | ||
# wait for the buildpack scripts to finish | ||
echo "Starting to wait for agent process to start" | ||
timeout 120s "${DATADOG_DIR}/scripts/check_datadog.sh" | ||
|
||
/bin/bash /home/vcap/app/.datadog/scripts/update_agent_config_restart.sh | ||
echo "$DD_NODE_AGENT_TAGS" | ||
|
||
/bin/bash "${DATADOG_DIR}/scripts/update_agent_config_restart.sh" | ||
} | ||
# for debugging purposes | ||
main "$@" >> "$DEBUG_FILE" 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters