Skip to content

Instantly share code, notes, and snippets.

@johnhamelink
Created March 3, 2016 02:37
Show Gist options
  • Select an option

  • Save johnhamelink/923c12b918f826fcfa39 to your computer and use it in GitHub Desktop.

Select an option

Save johnhamelink/923c12b918f826fcfa39 to your computer and use it in GitHub Desktop.
defmodule Api.Discovery do
require Logger
def discover do
# Attempt to connect to any other outside nodes.
# This command makes use of the /opt/api/.hosts.erlang file
hosts_path = Path.expand("/opt/api/.hosts.erlang")
case File.exists?(hosts_path) do
true ->
Logger.info("Attempting to join cluster")
:net_adm.world(:verbose)
false ->
Logger.warn("Couldn't find #{hosts_path} file - not joining cluster")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment