mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
55 lines
1.5 KiB
Elixir
55 lines
1.5 KiB
Elixir
defmodule TeslaMate.Application do
|
|
use Application
|
|
|
|
require Logger
|
|
|
|
def start(_type, _args) do
|
|
Logger.info("Version: #{Application.spec(:teslamate, :vsn) || "???"}")
|
|
|
|
# Disable log entries
|
|
:ok = :telemetry.detach({Phoenix.Logger, [:phoenix, :socket_connected]})
|
|
:ok = :telemetry.detach({Phoenix.Logger, [:phoenix, :channel_joined]})
|
|
|
|
Supervisor.start_link(children(), strategy: :one_for_one, name: TeslaMate.Supervisor)
|
|
end
|
|
|
|
defp children do
|
|
mqtt_enabled? = !is_nil(Application.get_env(:teslamate, :mqtt))
|
|
|
|
case Application.get_env(:teslamate, :import_directory) do
|
|
nil ->
|
|
[
|
|
TeslaMate.Repo,
|
|
TeslaMate.Api,
|
|
TeslaMate.Updater,
|
|
{Phoenix.PubSub, name: TeslaMate.PubSub},
|
|
TeslaMateWeb.Endpoint,
|
|
TeslaMate.Terrain,
|
|
TeslaMate.Vehicles,
|
|
if(mqtt_enabled?, do: TeslaMate.Mqtt),
|
|
TeslaMate.Repair
|
|
]
|
|
|> Enum.reject(&is_nil/1)
|
|
|
|
import_directory ->
|
|
[
|
|
TeslaMate.Repo,
|
|
TeslaMate.Api,
|
|
TeslaMate.Updater,
|
|
{Phoenix.PubSub, name: TeslaMate.PubSub},
|
|
TeslaMateWeb.Endpoint,
|
|
{TeslaMate.Terrain, disabled: true},
|
|
{TeslaMate.Repair, limit: 250},
|
|
{TeslaMate.Import, directory: import_directory}
|
|
]
|
|
end
|
|
end
|
|
|
|
# Tell Phoenix to update the endpoint configuration
|
|
# whenever the application is updated.
|
|
def config_change(changed, _new, removed) do
|
|
TeslaMateWeb.Endpoint.config_change(changed, removed)
|
|
:ok
|
|
end
|
|
end
|