diff options
Diffstat (limited to 'src/server/Startup.cs')
| -rw-r--r-- | src/server/Startup.cs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/server/Startup.cs b/src/server/Startup.cs index a1b6eb1..4b7c097 100644 --- a/src/server/Startup.cs +++ b/src/server/Startup.cs @@ -1,5 +1,3 @@ -using System.Reflection; - namespace IOL.BookmarkThing.Server; public class Startup @@ -21,6 +19,16 @@ public class Startup return $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; } + public string QuartzDatabaseConnectionString() { + var host = Configuration.GetValue<string>("QUARTZ_DB_HOST"); + var port = Configuration.GetValue<string>("QUARTZ_DB_PORT"); + var database = Configuration.GetValue<string>("QUARTZ_DB_NAME"); + var user = Configuration.GetValue<string>("QUARTZ_DB_USER"); + var password = Configuration.GetValue<string>("QUARTZ_DB_PASSWORD"); + return $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; + } + + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDataProtection() @@ -46,6 +54,19 @@ public class Startup } }); + services.AddQuartz(options => { + options.UsePersistentStore(o => { + o.UsePostgres(QuartzDatabaseConnectionString()); + o.UseSerializer<QuartzJsonSerializer>(); + }); + options.UseMicrosoftDependencyInjectionJobFactory(); + options.RegisterJobs(); + }); + + services.AddQuartzHostedService(options => { + options.WaitForJobsToComplete = true; + }); + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.Cookie.Name = "bookmarkthing_session"; |
