Run cleanup when drone starts

New: Cleanup jobs will run when drone starts as well as every 24 hours
This commit is contained in:
Mark McDowall 2013-10-10 20:34:06 -07:00
parent 7ac77ecfcc
commit 8cfc9ef0a3
1 changed files with 14 additions and 2 deletions

View File

@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using NLog;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Housekeeping
{
public class HousekeepingService : IExecute<HousekeepingCommand>
public class HousekeepingService : IExecute<HousekeepingCommand>, IHandleAsync<ApplicationStartedEvent>
{
private readonly IEnumerable<IHousekeepingTask> _housekeepers;
private readonly Logger _logger;
@ -16,7 +18,7 @@ namespace NzbDrone.Core.Housekeeping
_logger = logger;
}
public void Execute(HousekeepingCommand message)
private void Clean()
{
_logger.Info("Running housecleaning tasks");
@ -32,5 +34,15 @@ namespace NzbDrone.Core.Housekeeping
}
}
}
public void Execute(HousekeepingCommand message)
{
Clean();
}
public void HandleAsync(ApplicationStartedEvent message)
{
Clean();
}
}
}