mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:36:31 +00:00
add loader and versioning
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Azaion.CommonSecurity;
|
||||
|
||||
@@ -56,4 +57,22 @@ public class SecurityConstants
|
||||
}
|
||||
};
|
||||
#endregion ExternalClientsConfig
|
||||
|
||||
public static InitConfig ReadInitConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(CONFIG_PATH))
|
||||
throw new FileNotFoundException(CONFIG_PATH);
|
||||
var configStr = File.ReadAllText(CONFIG_PATH);
|
||||
var config = JsonConvert.DeserializeObject<InitConfig>(configStr);
|
||||
|
||||
return config ?? DefaultInitConfig;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
return DefaultInitConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using Exception = System.Exception;
|
||||
|
||||
namespace Azaion.CommonSecurity.Services;
|
||||
|
||||
public class LoaderClient(LoaderClientConfig config, ILogger logger, CancellationToken ct = default)
|
||||
public class LoaderClient(LoaderClientConfig config, ILogger logger, CancellationToken ct = default) : IDisposable
|
||||
{
|
||||
private readonly DealerSocket _dealer = new();
|
||||
private readonly Guid _clientId = Guid.NewGuid();
|
||||
@@ -24,7 +24,7 @@ public class LoaderClient(LoaderClientConfig config, ILogger logger, Cancellatio
|
||||
{
|
||||
FileName = SecurityConstants.EXTERNAL_LOADER_PATH,
|
||||
Arguments = $"--port {config.ZeroMqPort} --api {config.ApiUrl}",
|
||||
CreateNoWindow = true
|
||||
//CreateNoWindow = true
|
||||
};
|
||||
|
||||
process.OutputDataReceived += (_, e) =>
|
||||
@@ -90,4 +90,14 @@ public class LoaderClient(LoaderClientConfig config, ILogger logger, Cancellatio
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_dealer.SendFrame(MessagePackSerializer.Serialize(new RemoteCommand(CommandType.Exit)));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_dealer.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user