初始化
This commit is contained in:
125
NewCRICS/Program.cs
Normal file
125
NewCRICS/Program.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using NewCRICS.Jobs;
|
||||
using Orleans.Configuration;
|
||||
using Quartz;
|
||||
namespace NewCRICS
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Host.UseOrleans(ooo =>
|
||||
{
|
||||
// <20><> Orleans <20>ͻ<EFBFBD><CDBB>˺ͷ<CBBA><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>
|
||||
ooo.Configure<GrainCollectionOptions>(options =>
|
||||
{
|
||||
options.CollectionAge = TimeSpan.FromMinutes(10); // <20>ӳ<EFBFBD>Grain<69><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
options.DeactivationTimeout = TimeSpan.FromMinutes(10);
|
||||
});
|
||||
|
||||
ooo.Configure<Orleans.Configuration.SchedulingOptions>(options =>
|
||||
{
|
||||
//options.MaxActiveThreads = Math.Max(4, Environment.ProcessorCount * 2);
|
||||
options.MaxPendingWorkItemsSoftLimit = 10000;
|
||||
options.DelayWarningThreshold = TimeSpan.FromSeconds(5);
|
||||
});
|
||||
|
||||
ooo.UseLocalhostClustering();
|
||||
ooo.AddRedisGrainStorage("RedisStorage", options =>
|
||||
{
|
||||
options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions
|
||||
{
|
||||
EndPoints = { "localhost:6379" },
|
||||
AbortOnConnectFail = false,
|
||||
};
|
||||
});
|
||||
});
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
|
||||
|
||||
builder.Services.AddQuartz(q =>
|
||||
{
|
||||
var jobKey = new JobKey("CacheSaveJob");
|
||||
q.AddJob<CacheSave>(opts => opts.WithIdentity(jobKey));
|
||||
|
||||
q.AddTrigger(opts => opts
|
||||
.ForJob(jobKey)
|
||||
.WithIdentity("CacheSaveJob-trigger")
|
||||
.WithCalendarIntervalSchedule(x =>
|
||||
{
|
||||
x.WithIntervalInMinutes(1).Build();
|
||||
})
|
||||
);
|
||||
|
||||
#region <EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>
|
||||
//var jobKey1 = new JobKey("Cache_Save");
|
||||
//q.AddJob<CacheSave>(opts => opts.WithIdentity(jobKey1));
|
||||
|
||||
//q.AddTrigger(opts => opts
|
||||
// .ForJob(jobKey1)
|
||||
// .WithIdentity("CacheSaveJob-trigger")
|
||||
// .StartAt(DateBuilder.TodayAt(h, m, s))
|
||||
// .WithCalendarIntervalSchedule(x => x
|
||||
// .WithIntervalInDays(1)
|
||||
// .InTimeZone(TimeZoneInfo.Local))
|
||||
//);
|
||||
//q.AddTrigger(opts => opts
|
||||
// .ForJob(jobKey1)
|
||||
// .WithIdentity("ExcelGenerateJob-trigger")
|
||||
// .WithCronSchedule("0 0 17 * * ?", (schedule) =>
|
||||
// {
|
||||
// schedule.WithMisfireHandlingInstructionDoNothing().InTimeZone(TimeZoneInfo.Local);
|
||||
// }) // ÿ<><C3BF>17:00
|
||||
//);
|
||||
|
||||
|
||||
//var jobKey2 = new JobKey("ScanExcel");
|
||||
//q.AddJob<ExcelScan>(opts => opts.WithIdentity(jobKey2));
|
||||
//q.AddTrigger(opts => opts
|
||||
// .ForJob(jobKey2)
|
||||
// .WithIdentity("ExcelScan-trigger")
|
||||
// .WithCalendarIntervalSchedule(x =>
|
||||
// {
|
||||
// x.WithIntervalInSeconds(30).Build();
|
||||
// })
|
||||
//);
|
||||
|
||||
|
||||
//var jobKey3 = new JobKey("DeleteFile");
|
||||
//q.AddJob<ExcelScan>(opts => opts.WithIdentity(jobKey3));
|
||||
//q.AddTrigger(opts => opts
|
||||
// .ForJob(jobKey3)
|
||||
// .WithIdentity("DeleteFile-trigger")
|
||||
// .WithCronSchedule("0 0 1 * * ?", (schedule) =>
|
||||
// {
|
||||
// schedule.WithMisfireHandlingInstructionDoNothing().InTimeZone(TimeZoneInfo.Local);
|
||||
// }) // ÿ<><C3BF>17:00
|
||||
//);
|
||||
#endregion
|
||||
|
||||
});
|
||||
builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user