graceful shutdown
This commit is contained in:
parent
ef7fff7302
commit
ac9ce3b4c2
@ -3,7 +3,13 @@ using InverterMon.Server.Persistence.Settings;
|
|||||||
|
|
||||||
namespace InverterMon.Server.InverterService;
|
namespace InverterMon.Server.InverterService;
|
||||||
|
|
||||||
class StatusRetriever(Database db, FelicitySolarInverter inverter, UserSettings userSettings, IConfiguration config, ILogger<StatusRetriever> log)
|
class StatusRetriever(
|
||||||
|
Database db,
|
||||||
|
FelicitySolarInverter inverter,
|
||||||
|
UserSettings userSettings,
|
||||||
|
IConfiguration config,
|
||||||
|
ILogger<StatusRetriever> log,
|
||||||
|
IHostApplicationLifetime appLife)
|
||||||
: BackgroundService
|
: BackgroundService
|
||||||
{
|
{
|
||||||
protected override async Task ExecuteAsync(CancellationToken c)
|
protected override async Task ExecuteAsync(CancellationToken c)
|
||||||
@ -16,6 +22,8 @@ class StatusRetriever(Database db, FelicitySolarInverter inverter, UserSettings
|
|||||||
await Task.Delay(5000);
|
await Task.Delay(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appLife.ApplicationStopping.Register(inverter.Close);
|
||||||
|
|
||||||
while (!c.IsCancellationRequested)
|
while (!c.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
inverter.Status.BatteryCapacity = userSettings.BatteryCapacity;
|
inverter.Status.BatteryCapacity = userSettings.BatteryCapacity;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user