46 lines
991 B
C#
46 lines
991 B
C#
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");
|
|
}
|
|
}
|
|
} |