diff --git a/.gitignore b/.gitignore index 32a515c0..34cab8fb 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,9 @@ node_modules # this depending on your deployment strategy. /priv/static/ +# Mnesia DBs +apps/*/priv/mnesia/ + # Lock file for Brew, since the versions aren't really stable & isolated anyway Brewfile.lock.json diff --git a/apps/core/lib/auth/mnesia_cluster_supervisor.ex b/apps/core/lib/auth/mnesia_cluster_supervisor.ex new file mode 100644 index 00000000..f3336624 --- /dev/null +++ b/apps/core/lib/auth/mnesia_cluster_supervisor.ex @@ -0,0 +1,17 @@ +defmodule Legendary.Auth.MnesiaClusterSupervisor do + use Supervisor + + def start_link(init_arg) do + Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__) + end + + @impl true + def init(_init_arg) do + children = [ + {Pow.Store.Backend.MnesiaCache, extra_db_nodes: Node.list()}, + Pow.Store.Backend.MnesiaCache.Unsplit + ] + + Supervisor.init(children, strategy: :one_for_one) + end +end diff --git a/apps/core/lib/core/application.ex b/apps/core/lib/core/application.ex index 5659576e..eb55b834 100644 --- a/apps/core/lib/core/application.ex +++ b/apps/core/lib/core/application.ex @@ -10,6 +10,7 @@ defmodule Legendary.Core.Application do children = [ {Cluster.Supervisor, [topologies, [name: Legendary.Core.ClusterSupervisor]]}, + Legendary.Auth.MnesiaClusterSupervisor, # Start the Ecto repository Legendary.Core.Repo, # Start the Telemetry supervisor diff --git a/apps/core/mix.exs b/apps/core/mix.exs index 830e1f17..fa2ec399 100644 --- a/apps/core/mix.exs +++ b/apps/core/mix.exs @@ -120,7 +120,7 @@ defmodule Legendary.Core.MixProject do def application do [ mod: {Legendary.Core.Application, []}, - extra_applications: [:bamboo, :bamboo_smtp, :logger, :runtime_tools] + extra_applications: [:bamboo, :bamboo_smtp, :logger, :mnesia, :runtime_tools] ] end diff --git a/config/config.exs b/config/config.exs index 5c477cc7..bddaacda 100644 --- a/config/config.exs +++ b/config/config.exs @@ -43,7 +43,8 @@ config :core, :pow, controller_callbacks: Pow.Extension.Phoenix.ControllerCallbacks, mailer_backend: Legendary.AuthWeb.Pow.Mailer, web_mailer_module: Legendary.AuthWeb, - web_module: Legendary.AuthWeb + web_module: Legendary.AuthWeb, + cache_store_backend: Pow.Store.Backend.MnesiaCache config :core, email_from: "example@example.org" @@ -73,6 +74,8 @@ config :app, crontab: [ ] +config :mnesia, dir: to_charlist(File.cwd!) ++ '/apps/core/priv/mnesia' + import_config "email_styles.exs" import_config "admin.exs" diff --git a/config/prod.exs b/config/prod.exs index 52911af5..22af3f17 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -82,7 +82,6 @@ config :core, Legendary.CoreMailer, config :core, email_from: System.get_env("EMAIL_FROM") config :libcluster, - debug: true, topologies: [ kubernetes: [ strategy: Elixir.Cluster.Strategy.Kubernetes, @@ -94,8 +93,6 @@ config :libcluster, kubernetes_namespace: System.get_env("NAMESPACE", "legendary"), polling_interval: 10_000]]] -IO.puts Kernel.node - # ## Using releases (Elixir v1.9+) # # If you are doing OTP releases, you need to instruct Phoenix