Skip to content

Commit

Permalink
Run cleanup when drone starts
Browse files Browse the repository at this point in the history
New: Cleanup jobs will run when drone starts as well as every 24 hours
  • Loading branch information
markus101 committed Oct 11, 2013
1 parent 7ac77ec commit 8cfc9ef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/NzbDrone.Core/Housekeeping/HousekeepingService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,7 +18,7 @@ public HousekeepingService(IEnumerable<IHousekeepingTask> housekeepers, Logger l
_logger = logger;
}

public void Execute(HousekeepingCommand message)
private void Clean()
{
_logger.Info("Running housecleaning tasks");

Expand All @@ -32,5 +34,15 @@ public void Execute(HousekeepingCommand message)
}
}
}

public void Execute(HousekeepingCommand message)
{
Clean();
}

public void HandleAsync(ApplicationStartedEvent message)
{
Clean();
}
}
}

0 comments on commit 8cfc9ef

Please sign in to comment.