mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-21 21:53:01 +02:00
JobContext per Job
This commit is contained in:
parent
96d5b09391
commit
3fe3fc09b0
@ -67,14 +67,13 @@ public abstract class Job
|
||||
this.Log = LogManager.GetLogger(this.GetType());
|
||||
}
|
||||
|
||||
public IEnumerable<Job> Run(IServiceProvider serviceProvider)
|
||||
public IEnumerable<Job> Run(PgsqlContext context)
|
||||
{
|
||||
Log.Info($"Running job {JobId}");
|
||||
DateTime jobStart = DateTime.UtcNow;
|
||||
context.Attach(this);
|
||||
Job[]? ret = null;
|
||||
|
||||
using IServiceScope scope = serviceProvider.CreateScope();
|
||||
PgsqlContext context = scope.ServiceProvider.GetRequiredService<PgsqlContext>();
|
||||
try
|
||||
{
|
||||
this.state = JobState.Running;
|
||||
|
@ -172,7 +172,9 @@ public static class Tranga
|
||||
{
|
||||
Thread t = new(() =>
|
||||
{
|
||||
job.Run(serviceProvider);
|
||||
using IServiceScope jobScope = serviceProvider.CreateScope();
|
||||
PgsqlContext jobContext = jobScope.ServiceProvider.GetRequiredService<PgsqlContext>();
|
||||
job.Run(jobContext);
|
||||
});
|
||||
RunningJobs.Add(t, job);
|
||||
t.Start();
|
||||
|
Loading…
x
Reference in New Issue
Block a user