-
Notifications
You must be signed in to change notification settings - Fork 0
/
observer
executable file
·23 lines (18 loc) · 1.11 KB
/
observer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
set -e
if [ -z "$RELEASE_COOKIE" ]; then
echo "Set the RELEASE_COOKIE your project uses in the RELEASE_COOKIE ENV value before running this script"
exit 1
fi
# Get the first IPv6 address returned
ip_array=( $(fly ips private | awk '(NR>1){ print $5 }') )
IP=${ip_array[0]}
# Get the Fly app name. Assumes it is used as part of the full node name
APP_NAME=`fly info --name`
FULL_NODE_NAME="${APP_NAME}@${IP}"
echo Attempting to connect to $FULL_NODE_NAME
# Export the BEAM settings for running the "iex" command.
# This creates a local node named "my_remote". The name used isn't important.
# The cookie must match the cookie used in your project so the two nodes can connect.
# Waits for 5 seconds after connecting to the first node to finish connecting the rest of the cluster.
iex --erl "-proto_dist inet6_tcp" --sname my_remote --cookie ${RELEASE_COOKIE} -e "IO.inspect(Node.connect(:'${FULL_NODE_NAME}'), label: \"Node Connected?\"); IO.puts(\"Waiting five seconds to finish connecting to other nodes in the cluster\"); Process.sleep(5000); IO.inspect(Node.list(), label: \"Connected Nodes\"); :observer.start"