Probes connect to the panel directly and get the agent list as desired state. CI signs the image digest of agent and probe releases, the panel forwards the manifest, and a host updater verifies it with a local public key, pulls by digest and rolls back when the new version is unhealthy.
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Fleet.Core;
|
|
using Fleet.Hosting;
|
|
using Monitor.Agent;
|
|
|
|
TimeProvider time = TimeProvider.System;
|
|
INodeLog log = new ConsoleNodeLog(time);
|
|
|
|
if (PlatformCheck.VerifyCrypto() is { } problem)
|
|
{
|
|
log.Error("startup failed", ("err", problem));
|
|
return 1;
|
|
}
|
|
|
|
string configPath = "/etc/monitor/agent.json";
|
|
for (int i = 0; i < args.Length - 1; i++)
|
|
{
|
|
if (args[i] == "--config")
|
|
{
|
|
configPath = args[i + 1];
|
|
}
|
|
}
|
|
|
|
AgentConfig config;
|
|
LoadedNodeIdentity identity;
|
|
try
|
|
{
|
|
config = NodeConfig.Load(configPath, AgentConfigContext.Default.AgentConfig);
|
|
identity = LoadedNodeIdentity.Load(config.Fleet.IdentityDir);
|
|
}
|
|
catch (Exception ex) when (ex is IOException or InvalidDataException or InvalidOperationException or System.Text.Json.JsonException or System.Security.Cryptography.CryptographicException)
|
|
{
|
|
log.Error("startup failed", ("err", ex.Message));
|
|
return 1;
|
|
}
|
|
|
|
using (identity)
|
|
{
|
|
using var app = new AgentApp(config, identity, Path.GetDirectoryName(Path.GetFullPath(configPath))!, time, log);
|
|
await ServiceShell.RunAsync(app.RunAsync, log);
|
|
}
|
|
|
|
return 0;
|