Systemd Socket Activation

This commit is contained in:
Jöran Malek 2024-01-13 17:46:11 +01:00
parent 99202af871
commit 3a30daf597

View file

@ -65,11 +65,22 @@ builder.WebHost.ConfigureKestrel((context, options) =>
var path = PathEx.ExpandPath(pdnsOptions.Socket); var path = PathEx.ExpandPath(pdnsOptions.Socket);
FileInfo file = new(path); FileInfo file = new(path);
file.Directory!.Create(); file.Directory!.Create();
bool isSystemd = false;
options.UseSystemd(options =>
{
isSystemd = true;
options.UseConnectionHandler<PowerDnsHandler>();
});
if (!isSystemd)
{
file.Delete();
options.ListenUnixSocket(path, options => options.ListenUnixSocket(path, options =>
{ {
options.UseConnectionHandler<PowerDnsHandler>(); options.UseConnectionHandler<PowerDnsHandler>();
}); });
} }
}
}); });
var app = builder.Build(); var app = builder.Build();