Files
warmbly/realtime/lib/realtime/application.ex
T
Matthew Meszaros ce870a15b3 ci: fix Elixir formatting / Elixir version / missing pnpm lockfile
- realtime/: `mix format` applied; long Logger calls reformatted across
  config/runtime/application/connections/user_channel/user_socket/
  endpoint. CI's "Check formatting" step now passes.
- CI Elixir bumped from 1.16 → 1.18 (with OTP 27) to match mix.exs's
  `~> 1.18` requirement. Phoenix 1.8.7 + plug 1.19 also expect this.
- web/: generate + commit pnpm-lock.yaml so actions/setup-node@v4's
  pnpm cache step + `pnpm install --frozen-lockfile` can resolve.
2026-05-23 16:17:27 +00:00

57 lines
1.8 KiB
Elixir

defmodule Realtime.Application do
@moduledoc false
use Application
require Logger
@impl true
def start(_type, _args) do
# Ensure postgrex application is fully started before we start the Repo.
# In releases, dependent apps can sometimes be stopped during restart cycles
# while named processes (like PubSub.Supervisor) survive, causing conflicts.
{:ok, _} = Application.ensure_all_started(:postgrex)
children = [
# Database repository for API key lookups
Realtime.Repo,
# Redis connection pool for rate limiting and distributed state
Realtime.Redis,
# Phoenix PubSub for internal message broadcasting
{Phoenix.PubSub, name: Realtime.PubSub},
# Phoenix Endpoint (WebSocket server)
RealtimeWeb.Endpoint,
# Connection tracker
{Realtime.Connections, []},
# Google Pub/Sub subscriber supervisor
{Realtime.CloudPubSub.Supervisor, []}
]
opts = [strategy: :one_for_one, name: Realtime.Supervisor]
Logger.info("Starting Realtime application...")
Logger.info("Redis URL: #{Application.get_env(:realtime, :redis_url, "not configured")}")
Logger.info(
"Connection limits: user=#{Application.get_env(:realtime, :max_connections_per_user, 10)}, ip=#{Application.get_env(:realtime, :max_connections_per_ip, 50)}, global=#{Application.get_env(:realtime, :max_connections_global, 100_000)}"
)
Logger.info(
"Rate limits: message=#{Application.get_env(:realtime, :rate_limit_ws_message, 120)}/min, join=#{Application.get_env(:realtime, :rate_limit_ws_join, 30)}/min, event=#{Application.get_env(:realtime, :rate_limit_ws_event, 60)}/min"
)
Supervisor.start_link(children, opts)
end
@impl true
def config_change(changed, _new, removed) do
RealtimeWeb.Endpoint.config_change(changed, removed)
:ok
end
end