931 B · text History 44bc4f7
#!/bin/sh
# Sourced by every `bin/cartosnap_app <command>`. In Kubernetes, POD_IP
# comes from the downward API (app.yml) and names the node
# cartosnap_app@<pod ip>, which is how libcluster's Kubernetes strategy
# (config/runtime.exs) addresses its peers. Every replica must share
# RELEASE_COOKIE (from the elixir-args Secret) to connect.
#
# `remote` / `eval` / `rpc` need the name too, to find the running node;
# the temporary BEAM they start picks its own name, so there's no clash.

if [ -n "${POD_IP:-}" ]; then
  export RELEASE_DISTRIBUTION=name
  export RELEASE_NODE="cartosnap_app@${POD_IP}"
fi

case ${RELEASE_COMMAND:-} in
  start*|daemon*)
    # Pin the distribution port, so it's predictable from peers and matches
    # the headless Service; otherwise BEAM picks a random one each boot.
    export ELIXIR_ERL_OPTIONS="${ELIXIR_ERL_OPTIONS:-} -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9100"
    ;;
esac