From 4687e93ed3497721527cd5722f50445f0d44e010 Mon Sep 17 00:00:00 2001 From: Jake Morrison Date: Mon, 1 Jan 2024 22:01:08 -0600 Subject: [PATCH] Configure email, tailwind, opentelemetry --- config/config.exs | 3 -- config/dev.exs | 5 +- .../application.ex | 49 +++++++++++++------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/config/config.exs b/config/config.exs index 950fca2..4df198e 100644 --- a/config/config.exs +++ b/config/config.exs @@ -17,9 +17,6 @@ config :absinthe_federation_example, AbsintheFederationExampleWeb.Endpoint, config :absinthe_federation_example, AbsintheFederationExample.Mailer, adapter: Swoosh.Adapters.Local -# Swoosh API client is needed for adapters other than SMTP. -config :swoosh, :api_client, false - # Configure esbuild (the version is required) config :esbuild, version: "0.17.11", diff --git a/config/dev.exs b/config/dev.exs index 116e1bf..994e12e 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -26,8 +26,8 @@ config :absinthe_federation_example, AbsintheFederationExampleWeb.Endpoint, debug_errors: true, secret_key_base: "lnecsauLHdxwbypuKltf4vWanMlI1tMk5jTUooXic+ry6AsmQYRAI6bVVi8sO88/", watchers: [ - # Start the esbuild watcher by calling Esbuild.install_and_run(:default, args) - esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]} + esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}, + tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]} ] # config :logger, :default_formatter, @@ -75,6 +75,7 @@ config :absinthe_federation_example, AbsintheFederationExampleWeb.Endpoint, patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", + ~r"lib/absinthe_federation_example_web/(controllers|live|components)/.*(ex|heex)$", ~r"lib/absinthe_federation_example_web/(live|views)/.*(ex)$", ~r"lib/absinthe_federation_example_web/templates/.*(eex)$" ] diff --git a/lib/absinthe_federation_example/application.ex b/lib/absinthe_federation_example/application.ex index 32fbd7d..e9e762c 100644 --- a/lib/absinthe_federation_example/application.ex +++ b/lib/absinthe_federation_example/application.ex @@ -1,31 +1,48 @@ defmodule AbsintheFederationExample.Application do - # See https://hexdocs.pm/elixir/Application.html - # for more information on OTP Applications @moduledoc false use Application + require Logger + + @app :absinthe_federation_example + @impl true def start(_type, _args) do + OpentelemetryEcto.setup([@app, :repo]) + :opentelemetry_cowboy.setup() + OpentelemetryPhoenix.setup(adapter: :cowboy2) + OpentelemetryLiveView.setup() + + roles = Application.get_env(@app, :roles, [:api]) + Logger.info("Starting with roles: #{inspect(roles)}") + children = [ - # Start the Ecto repository - AbsintheFederationExample.Repo, - # Start the Telemetry supervisor - AbsintheFederationExampleWeb.Telemetry, - # Start the PubSub system - {Phoenix.PubSub, name: AbsintheFederationExample.PubSub}, - # Start the Endpoint (http/https) - AbsintheFederationExampleWeb.Endpoint - # Start a worker by calling: AbsintheFederationExample.Worker.start_link(arg) - # {AbsintheFederationExample.Worker, arg} - ] - - # See https://hexdocs.pm/elixir/Supervisor.html - # for other strategies and supported options + List.flatten([ + AbsintheFederationExampleWeb.Telemetry, + AbsintheFederationExample.Repo, + {DNSCluster, query: Application.get_env(:phoenix_container_example, :dns_cluster_query) || :ignore}, + {Phoenix.PubSub, name: PhoenixContainerExample.PubSub}, + # Start the Finch HTTP client for sending emails + {Finch, name: PhoenixContainerExample.Finch}, + AbsintheFederationExampleWeb.Endpoint + cluster_supervisor() + ]) + opts = [strategy: :one_for_one, name: AbsintheFederationExample.Supervisor] Supervisor.start_link(children, opts) end + defp cluster_supervisor do + topologies = Application.get_env(:libcluster, :topologies, []) + + if length(topologies) > 0 do + [{Cluster.Supervisor, [topologies, [name: PhoenixContainerExample.ClusterSupervisor]]}] + else + [] + end + end + # Tell Phoenix to update the endpoint configuration # whenever the application is updated. @impl true