feat(agent): start Diagnostics.Writer when dump_dir is configured

This commit is contained in:
Carsten 2026-04-22 22:23:56 +02:00
parent 3a32af4ff9
commit 2bb901873f

View file

@ -9,6 +9,8 @@ defmodule ProxmoxAgent.Application do
case load_config() do case load_config() do
{:ok, cfg} -> {:ok, cfg} ->
Logger.info("agent: starting with host_id=#{cfg.host_id}") Logger.info("agent: starting with host_id=#{cfg.host_id}")
:ok = ProxmoxAgent.Diagnostics.configure(cfg.dump_dir)
diagnostics_children(ProxmoxAgent.Diagnostics.dump_dir()) ++
[{ProxmoxAgent.Reporter, cfg}] [{ProxmoxAgent.Reporter, cfg}]
{:error, reason} -> {:error, reason} ->
@ -19,6 +21,9 @@ defmodule ProxmoxAgent.Application do
Supervisor.start_link(children, strategy: :one_for_one, name: ProxmoxAgent.Supervisor) Supervisor.start_link(children, strategy: :one_for_one, name: ProxmoxAgent.Supervisor)
end end
defp diagnostics_children(nil), do: []
defp diagnostics_children(dir), do: [{ProxmoxAgent.Diagnostics.Writer, [dir: dir]}]
defp load_config do defp load_config do
path = path =
System.get_env("AGENT_CONFIG") || System.get_env("AGENT_CONFIG") ||