mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 03:48:19 +02:00
Move Configuration of Workers to separate method
This commit is contained in:
@@ -145,6 +145,8 @@ using (IServiceScope scope = app.Services.CreateScope())
|
|||||||
|
|
||||||
Tranga.StartLogger();
|
Tranga.StartLogger();
|
||||||
|
|
||||||
|
Tranga.AddDefaultWorkers();
|
||||||
|
|
||||||
Tranga.PeriodicWorkerStarterThread.Start(app.Services);
|
Tranga.PeriodicWorkerStarterThread.Start(app.Services);
|
||||||
|
|
||||||
app.UseCors("AllowAll");
|
app.UseCors("AllowAll");
|
||||||
|
@@ -40,7 +40,10 @@ public static class Tranga
|
|||||||
BasicConfigurator.Configure();
|
BasicConfigurator.Configure();
|
||||||
Log.Info("Logger Configured.");
|
Log.Info("Logger Configured.");
|
||||||
Log.Info(TRANGA);
|
Log.Info(TRANGA);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void AddDefaultWorkers()
|
||||||
|
{
|
||||||
AddWorker(UpdateMetadataWorker);
|
AddWorker(UpdateMetadataWorker);
|
||||||
AddWorker(SendNotificationsWorker);
|
AddWorker(SendNotificationsWorker);
|
||||||
AddWorker(UpdateChaptersDownloadedWorker);
|
AddWorker(UpdateChaptersDownloadedWorker);
|
||||||
@@ -51,7 +54,12 @@ public static class Tranga
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static HashSet<BaseWorker> AllWorkers { get; private set; } = new ();
|
internal static HashSet<BaseWorker> AllWorkers { get; private set; } = new ();
|
||||||
public static void AddWorker(BaseWorker worker) => AllWorkers.Add(worker);
|
|
||||||
|
public static void AddWorker(BaseWorker worker)
|
||||||
|
{
|
||||||
|
Log.Debug($"Adding {worker} to AllWorkers.");
|
||||||
|
AllWorkers.Add(worker);
|
||||||
|
}
|
||||||
public static void AddWorkers(IEnumerable<BaseWorker> workers)
|
public static void AddWorkers(IEnumerable<BaseWorker> workers)
|
||||||
{
|
{
|
||||||
foreach (BaseWorker baseWorker in workers)
|
foreach (BaseWorker baseWorker in workers)
|
||||||
@@ -67,6 +75,7 @@ public static class Tranga
|
|||||||
foreach (BaseWorker worker in baseWorkers)
|
foreach (BaseWorker worker in baseWorkers)
|
||||||
{
|
{
|
||||||
StopWorker(worker);
|
StopWorker(worker);
|
||||||
|
Log.Debug($"Removing {removeWorker} from AllWorkers.");
|
||||||
AllWorkers.Remove(worker);
|
AllWorkers.Remove(worker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user