init
This commit is contained in:
46
src/Service/Jobs/StartupRegistry.cs
Normal file
46
src/Service/Jobs/StartupRegistry.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Net;
|
||||
using Core;
|
||||
using FluentScheduler;
|
||||
using Interface.Jobs;
|
||||
|
||||
namespace Service.Jobs;
|
||||
|
||||
public class StartupRegistry : Registry, IStartupRegistry
|
||||
{
|
||||
public StartupRegistry()
|
||||
{
|
||||
Schedule(Job).ToRunNow();
|
||||
}
|
||||
|
||||
public async void Job()
|
||||
{
|
||||
try
|
||||
{
|
||||
// await JobExecute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
await WxNotify.SendCommonAsync($"StartupRegistry.Job() error: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task JobExecute()
|
||||
{
|
||||
var commands = new[]
|
||||
{
|
||||
"chmod 777 /var/run/docker.sock",
|
||||
};
|
||||
|
||||
var (responseCode, _) = await Command.ExecAsync(commands);
|
||||
|
||||
if (responseCode != HttpStatusCode.OK)
|
||||
{
|
||||
await WxNotify.SendCommonAsync($"StartupRegistry.Job() error: {responseCode}");
|
||||
}
|
||||
else
|
||||
{
|
||||
await WxNotify.SendCommonAsync("StartupRegistry.Job() success");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user