dotfiles/app/lib/prymn/application.ex
Nikos Papadakis be7f584010
app: a nice poc background connection with the agent
Dynamically supervise a GRPC connection and keep it alive for a while,
using a timeout to kill the process on inactivity.

The Connection GenServer keeps the connection alive, while listening to
a health stream from the GRPC endpoint, notifying any subscribed
listeners about changes to health.

This health is then propagated to the main servers page.

Also create a looping get_sys_info which retrieves some basic system
information.
2023-08-26 00:51:04 +03:00

38 lines
1 KiB
Elixir

defmodule Prymn.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children = [
# Start the Telemetry supervisor
PrymnWeb.Telemetry,
# Start the Ecto repository
Prymn.Repo,
# Start the PubSub system
{Phoenix.PubSub, name: Prymn.PubSub},
# Start Finch
{Finch, name: Prymn.Finch},
# Start the Endpoint (http/https)
PrymnWeb.Endpoint,
# Start the Agents (dynamic GRPC connections) supervisor
Prymn.Agents.Supervisor
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Prymn.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
PrymnWeb.Endpoint.config_change(changed, removed)
:ok
end
end