Re-enable hot reloading & Add PhoenixProfiler

This commit is contained in:
Mayel de Borniol 2022-10-01 09:25:10 +13:00
parent 700995cdbb
commit 3f8d629d28
8 changed files with 33 additions and 20 deletions

View file

@ -62,6 +62,8 @@ config :bonfire, Bonfire.Web.Endpoint,
] ++ path_dep_patterns
]
config :bonfire, Bonfire.Web.Endpoint, phoenix_profiler: [server: Bonfire.Web.Profiler]
config :logger, :console,
level: :debug,
# truncate: :infinity,

View file

@ -31,6 +31,8 @@ defmodule Bonfire.Application do
# include GraphQL API
def applications(env, true = _with_graphql?) do
IO.puts("Enabling the GraphQL API...")
[
# use persistent_term backend for Absinthe
{Absinthe.Schema, Bonfire.API.GraphQL.Schema}
@ -54,21 +56,20 @@ defmodule Bonfire.Application do
# PubSub
{Phoenix.PubSub, [name: Bonfire.PubSub, adapter: Phoenix.PubSub.PG2]},
# Persistent Data Services
Pointers.Tables
Pointers.Tables,
# Bonfire.Data.AccessControl.Accesses,
## these populate on first call, so no need to run on startup:
# Bonfire.Common.ContextModules,
# Bonfire.Common.QueryModules,
# Bonfire.Federate.ActivityPub.FederationModules
{PhoenixProfiler, name: Bonfire.Web.Profiler}
]
# 6 hours
@default_cache_ttl 1_000 * 60 * 60 * 6
# Stuff that depends on all the above
# Stuff that depends on the Endpoint and/or the above
@apps_after [
# Web app
@endpoint_module,
# Job Queue
{Oban, Application.fetch_env!(:bonfire, Oban)},
%{
@ -91,14 +92,17 @@ defmodule Bonfire.Application do
]
def applications(:test, _any) do
# ++ [Bonfire.Web.FakeRemoteEndpoint]
# ++ [Bonfire.Web.FakeRemoteEndpoint] # NOTE: enable for tests that require two running instances
@apps_before ++
[@endpoint_module] ++
@apps_after
end
# default apps
def applications(_env, _any) do
@apps_before ++ @apps_after
@apps_before ++
[@endpoint_module] ++
@apps_after
end
# Tell Phoenix to update the endpoint configuration

View file

@ -1,8 +1,22 @@
defmodule Bonfire.Web.Endpoint do
use Phoenix.Endpoint, otp_app: :bonfire
use Bonfire.Web.EndpointTemplate
alias Bonfire.Common.Utils
alias Bonfire.Common.Config
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
plug(Phoenix.LiveReloader)
plug(Phoenix.CodeReloader)
plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :bonfire)
plug(PhoenixProfiler)
end
plug(Bonfire.Web.Router)
def include_assets(conn) do
include_assets(conn, :top)
include_assets(conn, :bottom)

View file

@ -5,7 +5,6 @@ defmodule Bonfire.Web.EndpointTemplate do
quote do
# make sure this comes before the Phoenix endpoint
use Bonfire.ErrorReporting
use Phoenix.Endpoint, otp_app: :bonfire
import Bonfire.Common.Extend
alias Bonfire.Web.EndpointTemplate
@ -64,16 +63,6 @@ defmodule Bonfire.Web.EndpointTemplate do
only: ~w(css images js favicon.ico robots.txt cache_manifest.json)
)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
# FIXME: doesn't work when defined in template macro
# if code_reloading? do
# socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
# plug Phoenix.LiveReloader
# plug Phoenix.CodeReloader
# plug Phoenix.Ecto.CheckRepoStatus, otp_app: :bonfire
# end
plug(Phoenix.LiveDashboard.RequestLogger,
param_key: "request_logger",
cookie_key: "request_logger"
@ -93,8 +82,6 @@ defmodule Bonfire.Web.EndpointTemplate do
plug(Plug.MethodOverride)
plug(Plug.Head)
plug(Plug.Session, EndpointTemplate.session_options())
plug(Bonfire.Web.Router)
end
end

View file

@ -1,3 +1,6 @@
defmodule Bonfire.Web.FakeRemoteEndpoint do
use Phoenix.Endpoint, otp_app: :bonfire
use Bonfire.Web.EndpointTemplate
plug(Bonfire.Web.Router)
end

View file

@ -123,7 +123,8 @@ defmodule Bonfire.Web.Router do
metrics: Bonfire.Web.Telemetry,
# metrics: FlamegraphsWeb.Telemetry,
additional_pages: [
flame_on: FlameOn.DashboardPage
flame_on: FlameOn.DashboardPage,
_profiler: {PhoenixProfiler.Dashboard, []}
]
)
end

View file

@ -262,6 +262,7 @@ defmodule Bonfire.MixProject do
{:recode, "~> 0.4", only: :dev},
# API client needed for changelog generation
{:neuron, "~> 5.0", only: :dev, override: true},
{:phoenix_profiler, "~> 0.2.0", only: :dev},
# tests
{:floki, ">= 0.0.0", only: [:dev, :test]},

View file

@ -186,6 +186,7 @@
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.18.1", "1e1703e26d0580dbd84e9b668e6da164a368f125dfa3d813c9a098da508e2a72", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6 or ~> 1.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b785e1cc13b05e6d9482d3ca1eedfb24e8113fd6421b47996ba16b9d20869706"},
"phoenix_meta_tags": {:hex, :phoenix_meta_tags, "0.1.9", "ba7b26b5304323fb92a8a1a6d4cf6103d21f6283df5de9471f9d25a2e06c080d", [:mix], [{:phoenix_html, "~> 2.10 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "3305beee9f951f84ad367b44e2f39df2887195be8a46481a6e33f4b109723428"},
"phoenix_profiler": {:hex, :phoenix_profiler, "0.2.0", "115d446512dd5b1435d42ba58e506f98a94db45ffa115699969c7c59f160a15e", [:mix], [{:phoenix_live_dashboard, "~> 0.7.0 or ~> 0.6.0 or ~> 0.5.0", [hex: :phoenix_live_dashboard, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.18.0 or ~> 0.17.0 or ~> 0.16.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "f1764a962e5b7bbe18102e930a522fc0baf37f9c02a5afc7726b33cae68bda4f"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
"phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"},
"plug": {:hex, :plug, "1.13.6", "187beb6b67c6cec50503e940f0434ea4692b19384d47e5fdfd701e93cadb4cc2", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02b9c6b9955bce92c829f31d6284bf53c591ca63c4fb9ff81dfd0418667a34ff"},