Add simple unix socket server
This commit is contained in:
parent
2df375c7f7
commit
69cea17dfd
3 changed files with 26 additions and 7 deletions
|
@ -1,5 +0,0 @@
|
|||
namespace netsd.Handlers;
|
||||
|
||||
public class Daemon
|
||||
{
|
||||
}
|
18
netsd/Handlers/Init.cs
Normal file
18
netsd/Handlers/Init.cs
Normal 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();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,14 @@
|
|||
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#");
|
||||
rootCommand.AddCommand(daemonCommand);
|
||||
rootCommand.AddCommand(initCommand);
|
||||
|
||||
initCommand.SetHandler((() =>
|
||||
{
|
||||
new Init();
|
||||
}));
|
||||
|
||||
return await rootCommand.InvokeAsync(args);
|
||||
|
|
Reference in a new issue