#!/bin/sh

# # Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
#   daemon*)
#     HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
#     export HEART_COMMAND
#     export ELIXIR_ERL_OPTIONS="-heart"
#     ;;
#   *)
#     ;;
# esac

# # Set the release to load code on demand (interactive) instead of preloading (embedded).
# export RELEASE_MODE=interactive

# Set the release to work across nodes.
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
export RELEASE_DISTRIBUTION=name

# Check if we're in Kubernetes (POD_IP will be set)
if [ -n "$POD_IP" ]; then
  # Use pod IP for Erlang distribution — matches libcluster DNS strategy
  export RELEASE_NODE=${RELEASE_NODE:-<%= @release.name %>@${POD_IP}}
else
  # Fallback to Dokku naming for non-Kubernetes deployments
  export RELEASE_NODE=<%= @release.name %>@${DOKKU_APP_NAME:-aprsme}.web.${DOKKU_APP_INSTANCE:-1}
fi

export RELEASE_COOKIE=${RELEASE_COOKIE:-Euta32aoLfgADYz3TiSCpQP0Y3iD7AD3zu0ycYWI5lQ=}

#ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
#export RELEASE_DISTRIBUTION=name
#export RELEASE_NODE=$FLY_APP_NAME@$ip
