Files
NasRobot/src/Service/Jobs/StartupRegistry.cs

46 lines
991 B
C#
Raw Normal View History

2025-02-27 16:58:21 +08:00
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");
}
}
}