Skip to content

Commit

Permalink
Merge pull request #55 from deskpro/add-ecs-container-name
Browse files Browse the repository at this point in the history
export CONTAINER_NAME as the task id if running under ECS
  • Loading branch information
fcoelho authored Aug 8, 2024
2 parents 5369ced + 49014fa commit 557cc86
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion usr/local/sbin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ export BOOT_LOG_LEVEL="${BOOT_LOG_LEVEL^^}"
export BOOT_LOG_LEVEL_EXEC="${BOOT_LOG_LEVEL_EXEC:-WARNING}"

# A name used in logs
export CONTAINER_NAME="${CONTAINER_NAME:-$(hostname)}"
if [ -z "${CONTAINER_NAME:-}" ]; then
# use the ECS task ID if that's available
if [ -n "${ECS_CONTAINER_METADATA_URI_V4:-}" ]; then
export CONTAINER_NAME="$(curl -s "${ECS_CONTAINER_METADATA_URI_V4}/task" | jq -r '.TaskARN | split("/") | last')"
else
export CONTAINER_NAME="$(hostname)"
fi
fi

# if LOGS_GID is set then we will add the vector to that group
if [ -n "$LOGS_GID" ]; then
Expand Down

0 comments on commit 557cc86

Please sign in to comment.