尽管有 RepeatForever(),为什么 Quartz.net 仍会关闭
Why Quartz.net is shutting down despite RepeatForever()
我在 asp.net 核心 Web 应用程序中使用 Quartz.Net 每 5 分钟触发一次作业。但是一段时间后它无缘无故地停止了......你能看看我的配置 or/and 到 Quartz 的日志吗?
这是我在program.cs
中的配置
services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionScopedJobFactory();
var jobKey = new JobKey("AppPushJob");
q.AddJob<AppPushJob>(opts => opts.WithIdentity(jobKey));
// Create a trigger for the job
q.AddTrigger(opts => opts
.ForJob(jobKey) // link to the AppPushJob
.WithIdentity("AppPushJob-trigger") // give the trigger a unique name
.WithCronSchedule("0 0/5 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * ?")); ; // run every 5 minutes de 6h à 23h, tous les jours
});
// Add the Quartz.NET hosted service
services.AddQuartzHostedService(
q => q.WaitForJobsToComplete = true
);
作业开始并执行它应该执行的操作。它重复这个过程几次然后关闭。
这是 START 事件的日志:
2021-02-04 14:05:28.026 +01:00 Information Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl
2021-02-04 14:05:28.026 +01:00 Information Quartz Scheduler v."3.2.3.0" created.
2021-02-04 14:05:28.027 +01:00 Information JobFactory set to: Quartz.Simpl.MicrosoftDependencyInjectionJobFactory
2021-02-04 14:05:28.027 +01:00 Information RAMJobStore initialized.
2021-02-04 14:05:28.032 +01:00 Information Scheduler meta-data: Quartz Scheduler (v3.2.3.0) 'QuartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'Quartz.Core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'Quartz.Simpl.DefaultThreadPool' - with 10 threads.
Using job-store 'Quartz.Simpl.RAMJobStore' - which does not support persistence. and is not clustered.
这是 END 事件的日志:
2021-02-04 14:25:30.767 +01:00 Debug Trigger instruction : NoInstruction
2021-02-04 14:25:51.659 +01:00 Debug Batch acquisition of 0 triggers
2021-02-04 14:26:14.861 +01:00 Debug Batch acquisition of 0 triggers
2021-02-04 14:26:26.741 +01:00 Information Scheduler "QuartzScheduler_$_NON_CLUSTERED" shutting down.
2021-02-04 14:26:26.744 +01:00 Information Scheduler QuartzScheduler_$_NON_CLUSTERED paused.
2021-02-04 14:26:26.752 +01:00 Debug Shutting down threadpool...
2021-02-04 14:26:26.752 +01:00 Debug Waiting for 0 threads to complete.
2021-02-04 14:26:26.752 +01:00 Debug No executing jobs remaining, all threads stopped.
2021-02-04 14:26:26.752 +01:00 Debug Shutdown of threadpool complete.
2021-02-04 14:26:26.758 +01:00 Information Scheduler QuartzScheduler_$_NON_CLUSTERED Shutdown complete.
我认为 cron 配置有误,但使用此配置时,我得到了相同的行为。
q.AddTrigger(opts => opts
.ForJob(jobKey) // link to the AppPushJob
.WithIdentity("AppPushJob-trigger") // give the trigger a unique name
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(5)
.RepeatForever()) //--> I thought this will be enough
);
你能告诉 le 这个配置有什么问题吗?
该作业应该在数据库中查找一些特定数据,并使用 ExpoSDK 将它们推送到 android 和 ios 应用程序。
谢谢
我发现 program.cs 主要方法在网站不再有访问者时退出。
我一直在寻找一种方法来强制它连续 运行,但我没有成功(我没想过要在 IIS 上查看)...所以我将我的程序移到我们的前端应用程序上(而不是然后后端)总是至少有一个访问者。
我在 asp.net 核心 Web 应用程序中使用 Quartz.Net 每 5 分钟触发一次作业。但是一段时间后它无缘无故地停止了......你能看看我的配置 or/and 到 Quartz 的日志吗?
这是我在program.cs
中的配置services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionScopedJobFactory();
var jobKey = new JobKey("AppPushJob");
q.AddJob<AppPushJob>(opts => opts.WithIdentity(jobKey));
// Create a trigger for the job
q.AddTrigger(opts => opts
.ForJob(jobKey) // link to the AppPushJob
.WithIdentity("AppPushJob-trigger") // give the trigger a unique name
.WithCronSchedule("0 0/5 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * ?")); ; // run every 5 minutes de 6h à 23h, tous les jours
});
// Add the Quartz.NET hosted service
services.AddQuartzHostedService(
q => q.WaitForJobsToComplete = true
);
作业开始并执行它应该执行的操作。它重复这个过程几次然后关闭。
这是 START 事件的日志:
2021-02-04 14:05:28.026 +01:00 Information Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl
2021-02-04 14:05:28.026 +01:00 Information Quartz Scheduler v."3.2.3.0" created.
2021-02-04 14:05:28.027 +01:00 Information JobFactory set to: Quartz.Simpl.MicrosoftDependencyInjectionJobFactory
2021-02-04 14:05:28.027 +01:00 Information RAMJobStore initialized.
2021-02-04 14:05:28.032 +01:00 Information Scheduler meta-data: Quartz Scheduler (v3.2.3.0) 'QuartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'Quartz.Core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'Quartz.Simpl.DefaultThreadPool' - with 10 threads.
Using job-store 'Quartz.Simpl.RAMJobStore' - which does not support persistence. and is not clustered.
这是 END 事件的日志:
2021-02-04 14:25:30.767 +01:00 Debug Trigger instruction : NoInstruction
2021-02-04 14:25:51.659 +01:00 Debug Batch acquisition of 0 triggers
2021-02-04 14:26:14.861 +01:00 Debug Batch acquisition of 0 triggers
2021-02-04 14:26:26.741 +01:00 Information Scheduler "QuartzScheduler_$_NON_CLUSTERED" shutting down.
2021-02-04 14:26:26.744 +01:00 Information Scheduler QuartzScheduler_$_NON_CLUSTERED paused.
2021-02-04 14:26:26.752 +01:00 Debug Shutting down threadpool...
2021-02-04 14:26:26.752 +01:00 Debug Waiting for 0 threads to complete.
2021-02-04 14:26:26.752 +01:00 Debug No executing jobs remaining, all threads stopped.
2021-02-04 14:26:26.752 +01:00 Debug Shutdown of threadpool complete.
2021-02-04 14:26:26.758 +01:00 Information Scheduler QuartzScheduler_$_NON_CLUSTERED Shutdown complete.
我认为 cron 配置有误,但使用此配置时,我得到了相同的行为。
q.AddTrigger(opts => opts
.ForJob(jobKey) // link to the AppPushJob
.WithIdentity("AppPushJob-trigger") // give the trigger a unique name
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(5)
.RepeatForever()) //--> I thought this will be enough
);
你能告诉 le 这个配置有什么问题吗?
该作业应该在数据库中查找一些特定数据,并使用 ExpoSDK 将它们推送到 android 和 ios 应用程序。
谢谢
我发现 program.cs 主要方法在网站不再有访问者时退出。 我一直在寻找一种方法来强制它连续 运行,但我没有成功(我没想过要在 IIS 上查看)...所以我将我的程序移到我们的前端应用程序上(而不是然后后端)总是至少有一个访问者。