Archived
0
0
Fork 0

Add simple unix socket server

This commit is contained in:
Daryl Ronningen 2022-11-15 23:27:37 -08:00
parent 2df375c7f7
commit 69cea17dfd
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
3 changed files with 26 additions and 7 deletions

View file

@ -1,5 +0,0 @@
namespace netsd.Handlers;
public class Daemon
{
}

18
netsd/Handlers/Init.cs Normal file
View file

@ -0,0 +1,18 @@
namespace netsd.Handlers;
public class Init
{
private readonly WebApplicationBuilder _socketBuilder = WebApplication.CreateBuilder();
public Init()
{
_socketBuilder.WebHost.ConfigureKestrel(options =>
{
options.ListenUnixSocket("/tmp/netsd.sock");
});
var app = _socketBuilder.Build();
app.Run();
}
}

View file

@ -1,8 +1,14 @@
using System.CommandLine; using System.CommandLine;
using netsd.Handlers;
var daemonCommand = new Command("init", "Run and bring up all default services"); var initCommand = new Command("init", "Run and bring up all default services");
var rootCommand = new RootCommand("Linux service manager written in C#"); var rootCommand = new RootCommand("Linux service manager written in C#");
rootCommand.AddCommand(daemonCommand); rootCommand.AddCommand(initCommand);
initCommand.SetHandler((() =>
{
new Init();
}));
return await rootCommand.InvokeAsync(args); return await rootCommand.InvokeAsync(args);