Run cleanup when drone starts

New: Cleanup jobs will run when drone starts as well as every 24 hours
pull/4/head
Mark McDowall 11 years ago
parent 7ac77ecfcc
commit 8cfc9ef0a3

@ -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();
}
}
}

Loading…
Cancel
Save