From 0df816689c9030d11cf9dec0768d1c1840f93685 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Mon, 5 Aug 2024 12:13:35 -0400 Subject: [PATCH] Re-enabled scheduled tasks after fixing scheduled lib. --- api/dub.json | 1 + api/dub.selections.json | 1 + api/source/app.d | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/api/dub.json b/api/dub.json index 3befe6c..96d0195 100644 --- a/api/dub.json +++ b/api/dub.json @@ -7,6 +7,7 @@ "handy-httpd": "~>8.4.1", "proper-d": "~>0.0.2", "requests": "~>2.1.3", + "scheduled": "~>1.4.0", "shared-utils": { "path": "../shared-utils" } diff --git a/api/dub.selections.json b/api/dub.selections.json index 43ea820..756b48c 100644 --- a/api/dub.selections.json +++ b/api/dub.selections.json @@ -8,6 +8,7 @@ "path-matcher": "1.2.0", "proper-d": "0.0.2", "requests": "2.1.3", + "scheduled": "1.4.0", "shared-utils": {"path":"../shared-utils"}, "slf4d": "3.0.1", "streams": "3.5.0", diff --git a/api/source/app.d b/api/source/app.d index 7413191..367bd61 100644 --- a/api/source/app.d +++ b/api/source/app.d @@ -4,6 +4,7 @@ import handy_httpd.handlers.file_resolving_handler; import handy_httpd.components.optional; import slf4d; import slf4d.default_provider; +import scheduled; import std.json; import std.stdio; @@ -43,16 +44,16 @@ void main() { serversMutex = new Mutex(); lastServerStatusTimestamp = Clock.currTime(); - // JobScheduler scheduler = JobScheduler.getDefault(); - // scheduler.addJob( - // &removeOldStartupRequests, - // new FixedIntervalSchedule(minutes(5)) - // ); - // scheduler.addJob( - // &checkForOutOfDateServerStatus, - // new FixedIntervalSchedule(minutes(1)) - // ); - // scheduler.start(); + JobScheduler scheduler = JobScheduler.getDefault(); + scheduler.addJob( + &removeOldStartupRequests, + new FixedIntervalSchedule(minutes(5)) + ); + scheduler.addJob( + &checkForOutOfDateServerStatus, + new FixedIntervalSchedule(minutes(1)) + ); + scheduler.start(); PathHandler handler = new PathHandler(); handler.addMapping(Method.POST, "/api/servers", &postServerStatus);