diff --git a/lib/cluster_demo/application.ex b/lib/cluster_demo/application.ex new file mode 100644 index 0000000..c18260d --- /dev/null +++ b/lib/cluster_demo/application.ex @@ -0,0 +1,30 @@ +defmodule ClusterDemo.Application do + # See https://hexdocs.pm/elixir/Application.html + # for more information on OTP Applications + @moduledoc false + + use Application + + def start(_type, _args) do + # List all child processes to be supervised + children = [ + # Starts a worker by calling: ClusterDemo.Worker.start_link(arg) + # {ClusterDemo.Worker, arg} + {Cluster.Supervisor, + [ + [ + swarm_dns_poll: [ + strategy: Cluster.Strategy.DNSPoll, + config: [query: "tasks.t_cluster_demo", node_basename: "cluster_demo"] + ] + ] + ] + } + ] + + # See https://hexdocs.pm/elixir/Supervisor.html + # for other strategies and supported options + opts = [strategy: :one_for_one, name: ClusterDemo.Supervisor] + Supervisor.start_link(children, opts) + end +end diff --git a/mix.exs b/mix.exs index 53ab004..4cf615f 100644 --- a/mix.exs +++ b/mix.exs @@ -14,14 +14,16 @@ defmodule ClusterDemo.MixProject do # Run "mix help compile.app" to learn about applications. def application do [ - extra_applications: [:logger] + extra_applications: [:logger], + mod: {ClusterDemo.Application, []} ] end # Run "mix help deps" to learn about dependencies. defp deps do [ - {:distillery, "~> 2.0"} + {:distillery, "~> 2.0"}, + {:libcluster, "~> 3.1"} ] end end diff --git a/mix.lock b/mix.lock index 6c9d584..6e958b8 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,6 @@ %{ "artificery": {:hex, :artificery, "0.4.2", "3ded6e29e13113af52811c72f414d1e88f711410cac1b619ab3a2666bbd7efd4", [:mix], [], "hexpm"}, "distillery": {:hex, :distillery, "2.1.0", "5f31c7771923c12dbb79dcd8d01c5913b07222f134c327e7ab026acdabae985b", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"}, + "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, + "libcluster": {:hex, :libcluster, "3.1.0", "461083b6c05ad117fadebb5e8986445d3045dbd1183b20d4865190aeb7873781", [:mix], [{:jason, "~> 1.1.2", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, }