Skip to content

Commit ece6785

Browse files
committed
Set node name for clustering based on ECS metadata
1 parent 51c2063 commit ece6785

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

rel/env.sh.eex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@
1818
# # RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
1919
# export RELEASE_DISTRIBUTION=name
2020
# export RELEASE_NODE=<%= @release.name %>
21+
22+
# Set node name for clustering based on ECS metadata
23+
# https://dmblake.com/elixir-clustering-with-libcluster-and-aws-ecs-fargate-in-cdk
24+
# https://docs.aws.amazon.com/AmazonECS/latest/userguide/task-metadata-endpoint-v4-fargate.html
25+
if [ ! -z "$ECS_CONTAINER_METADATA_URI_V4" ]; then
26+
export RELEASE_DISTRIBUTION=name
27+
# HOSTNAME=$(curl -s ${ECS_CONTAINER_METADATA_URI_V4}/task | jq -r '.Containers[0].Networks[0].IPv4Addresses[0]')
28+
HOSTNAME=$(wget -q ${ECS_CONTAINER_METADATA_URI_V4}/task -O -| jq -r '.Containers[0].Networks[0].IPv4Addresses[0]')
29+
export RELEASE_NODE="${RELEASE_NAME}@${HOSTNAME}"
30+
fi
31+
32+
# export DISTRIBUTION_PORT=7777

0 commit comments

Comments
 (0)