defmodule DaProductApp.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 = [ DaProductApp.DeviceRegistry, # Global settings cache (loads global_table once and refreshes periodically) # DaProductApp.GlobalSettings, # Existing children (keep all these) DaProductAppWeb.Telemetry, DaProductApp.Repo, DaProductApp.Repos.ShukriaMmsRepo, # Global settings cache (loads global_table once and refreshes periodically) DaProductApp.GlobalSettings, DaProductApp.TransactionRuleCache, # Prometheus metrics collector: attaches to HTTP/Ecto/payment/external-API # telemetry events, served via GET /monitoring/metrics DaProductApp.Telemetry.MetricsCollector, {DNSCluster, query: Application.get_env(:da_product_app, :dns_cluster_query) || :ignore}, {Phoenix.PubSub, name: DaProductApp.PubSub}, {Finch, name: DaProductApp.Finch}, {Cachex, name: :general_cache}, TwMerge.Cache, # NEW: Add Ranch TCP listener for ISO8583 # {DaProductApp.TCP.Supervisor, [port: 5000]}, # Customize port if needed # Start MQTT client supervisor {DaProductApp.MQTT.Supervisor, []}, # Ensure the client is started at boot: {Task, fn -> DaProductApp.MQTT.start_phoenix_client() end}, # Start Phoenix Endpoint (Bandit is configured here later) DaProductAppWeb.Endpoint ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: DaProductApp.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 DaProductAppWeb.Endpoint.config_change(changed, removed) :ok end defp oban_config do %{ name: Oban, repo: DaProductApp.Repo, # Use Basic Engine instead of Postgres engine: Oban.Engines.Basic, # Define your queues queues: [default: 10], # Disable PostgreSQL-based notifier notifier: Oban.Notifiers.Null, # Disable peer tracking (Postgres-only feature) peer: false } end # defp oban_config do # Application.fetch_env!(:da_product_app, Oban) # end end