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 maybe_start_optional_apps() base_children = [ DaProductApp.DeviceRegistry, # Existing children (keep all these) DaProductAppWeb.Telemetry, DaProductApp.Repo, DaProductApp.Repos.ShukriaMmsRepo, {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}, # Add Phoenix Endpoint last to ensure all dependencies are started DaProductAppWeb.Endpoint ] # Note: PaymentGatewayApp.Application is started automatically by OTP # when included as a dependency - no need to add it to supervision tree # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: DaProductApp.Supervisor] Supervisor.start_link(base_children, opts) end defp maybe_start_optional_apps do if System.get_env("INCLUDE_SOFT_POS", "false") == "true" do # When soft_pos_app is conditionally compiled in, it may not appear in # da_product_app.app applications list until a full recompile. if Code.ensure_loaded?(SoftPosApp.Application) do Application.ensure_all_started(:soft_pos_app) end end 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, engine: Oban.Engines.Basic, # Use Basic Engine instead of Postgres queues: [default: 10], # Define your queues notifier: Oban.Notifiers.Null, # Disable PostgreSQL-based notifier peer: false # Disable peer tracking (Postgres-only feature) } end #defp oban_config do # Application.fetch_env!(:da_product_app, Oban) # end end