#!/bin/sh
# Sourced by every `bin/waxx <command>` invocation. Only `start` and
# `daemon` need long-name distribution — they're the long-lived
# server nodes peer pods talk to. `remote`, `eval`, and `rpc` use
# unique auto-generated short names so they don't fight the running
# server for the `waxx@<pod-ip>` slot in epmd. Setting RELEASE_NODE for
# those would cause an epmd name collision: the new (short-lived)
# BEAM registers under the same name, evicts the running server from
# epmd, and now peer pods can't find it via dist any more — which
# typically takes the running pod down on its next inbound connect.
#
# POD_IP comes from the deployment's downward API. RELEASE_COOKIE
# comes from the elixir-args / waxx-secrets secret so every replica
# agrees on the Erlang cookie.
case ${RELEASE_COMMAND:-} in
start*|daemon*)
if [ -n "${POD_IP:-}" ]; then
echo "[env.sh] starting with name distribution as waxx@${POD_IP}" >&2
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE="waxx@${POD_IP}"
# Pin the inet_dist listener to a known port so it's predictable
# from peers and routable through any future NetworkPolicy.
# Without this BEAM picks a random ephemeral port each boot,
# which works under default k8s pod-to-pod TCP but breaks the
# moment a policy locks the namespace down.
export ELIXIR_ERL_OPTIONS="${ELIXIR_ERL_OPTIONS:-} -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9100"
else
echo "[env.sh] POD_IP is empty — falling back to local-only sname distribution" >&2
fi
;;
*)
# remote / eval / rpc — let mix release auto-pick a unique short
# name (`rem-<rand>@127.0.0.1`) and use `-remsh` to attach by the
# running node's long name (which it reads from this same script's
# state under start, baked into the release at build).
:
;;
esac
neiam
/waxx
waxx
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
1.8 KiB · text
History
ffe9912