Skip to content

Commit

Permalink
Configure email, tailwind, opentelemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
reachfh committed Jan 2, 2024
1 parent a37d7d3 commit 4687e93
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
3 changes: 0 additions & 3 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)$"
]
Expand Down
49 changes: 33 additions & 16 deletions lib/absinthe_federation_example/application.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4687e93

Please sign in to comment.