diff --git a/lib/beacon/live_admin/application.ex b/lib/beacon/live_admin/application.ex index 5e7814ef..375258ab 100644 --- a/lib/beacon/live_admin/application.ex +++ b/lib/beacon/live_admin/application.ex @@ -8,6 +8,7 @@ defmodule Beacon.LiveAdmin.Application do children = [ Beacon.LiveAdmin.Registry, {Phoenix.PubSub, name: Beacon.LiveAdmin.PubSub}, + %{id: :pg, start: {:pg, :start_link, [Beacon.LiveAdmin.Cluster.scope()]}}, Beacon.LiveAdmin.Cluster, Turboprop.Cache ] diff --git a/lib/beacon/live_admin/cluster.ex b/lib/beacon/live_admin/cluster.ex index e6dc019a..b183e5c8 100644 --- a/lib/beacon/live_admin/cluster.ex +++ b/lib/beacon/live_admin/cluster.ex @@ -10,6 +10,9 @@ defmodule Beacon.LiveAdmin.Cluster do @scope :beacon_cluster + @doc false + def scope, do: @scope + @doc false def start_link(opts) do GenServer.start_link(__MODULE__, opts, name: __MODULE__) @@ -18,7 +21,6 @@ defmodule Beacon.LiveAdmin.Cluster do @doc false @impl true def init(opts) do - {:ok, _} = :pg.start_link(@scope) :pg.monitor_scope(@scope) :ok = :net_kernel.monitor_nodes(true, node_type: :all) {:ok, opts} diff --git a/mix.lock b/mix.lock index 8d793ee9..7f6cbec0 100644 --- a/mix.lock +++ b/mix.lock @@ -1,7 +1,7 @@ %{ "accent": {:hex, :accent, "1.1.1", "20257356446d45078b19b91608f74669b407b39af891ee3db9ee6824d1cae19d", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.3", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "6d5afa50d4886e3370e04fa501468cbaa6c4b5fe926f72ccfa844ad9e259adae"}, "bandit": {:hex, :bandit, "1.6.7", "42f30e37a1c89a2a12943c5dca76f731a2313e8a2e21c1a95dc8241893e922d1", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "551ba8ff5e4fc908cbeb8c9f0697775fb6813a96d9de5f7fe02e34e76fd7d184"}, - "beacon": {:git, "https://github.com/BeaconCMS/beacon.git", "c243a4989deae142e2640be0f5e39253a88eca7a", []}, + "beacon": {:git, "https://github.com/BeaconCMS/beacon.git", "dfece41f6f8ffbbe4bf5b2368d452abb4cb0fc25", []}, "castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"}, "cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"}, "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"}, diff --git a/test/support/cluster.ex b/test/support/cluster.ex index 37695405..81c0219b 100644 --- a/test/support/cluster.ex +++ b/test/support/cluster.ex @@ -117,17 +117,35 @@ defmodule Beacon.LiveAdminTest.Cluster do rpc(node, MyApp.Repo, :stop, []) + rpc(node, Application, :put_env, [ + :my_app, + MyAppWeb.ProxyEndpoint, + http: [ip: {127, 0, 0, 1}, port: Enum.random(4030..4050)], + # adapter: Bandit.PhoenixAdapter, + server: true, + live_view: [signing_salt: "aaaaaaaa"], + secret_key_base: String.duplicate("a", 64), + render_errors: [ + formats: [ + html: Beacon.Web.ErrorHTML + ], + layout: false + ], + pubsub_server: MyApp.PubSub, + debug_errors: false + ]) + rpc(node, Application, :put_env, [ :my_app, MyAppWeb.Endpoint, - http: [ip: {127, 0, 0, 1}, port: Enum.random(4030..4099)], + http: [ip: {127, 0, 0, 1}, port: Enum.random(4051..4099)], # adapter: Bandit.PhoenixAdapter, server: true, live_view: [signing_salt: "aaaaaaaa"], secret_key_base: String.duplicate("a", 64), render_errors: [ formats: [ - html: MyApp.ErrorHTML + html: Beacon.Web.ErrorHTML ], layout: false ], @@ -139,6 +157,7 @@ defmodule Beacon.LiveAdminTest.Cluster do children = [ MyApp.Repo, + MyAppWeb.ProxyEndpoint, MyAppWeb.Endpoint, {Phoenix.PubSub, name: MyApp.PubSub}, {Beacon, beacon_config} diff --git a/test/support/site.ex b/test/support/site.ex index 784be0b1..dea70620 100644 --- a/test/support/site.ex +++ b/test/support/site.ex @@ -26,9 +26,18 @@ defmodule MyApp.Router do end end +defmodule MyAppWeb.ProxyEndpoint do + use Beacon.ProxyEndpoint, + otp_app: :my_app, + session_options: [store: :cookie, key: "_live_view_key", signing_salt: "/VEDsdfsffMnp5"], + fallback: MyAppWeb.Endpoint +end + defmodule MyAppWeb.Endpoint do use Phoenix.Endpoint, otp_app: :my_app + def proxy_endpoint, do: MyAppWeb.ProxyEndpoint + plug Plug.Session, store: :cookie, key: "_live_view_key",