From d913166f498ad68e130eecb956ff5e1facf2b262 Mon Sep 17 00:00:00 2001 From: Jimmy McDermott Date: Thu, 23 Jan 2020 21:41:02 -0500 Subject: [PATCH] Fail early if no scheduled jobs exist (#57) * Add precondition * Update to error message --- Sources/Jobs/JobsCommand.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/Jobs/JobsCommand.swift b/Sources/Jobs/JobsCommand.swift index 62c65ad..dc09098 100644 --- a/Sources/Jobs/JobsCommand.swift +++ b/Sources/Jobs/JobsCommand.swift @@ -108,6 +108,11 @@ public final class JobsCommand: Command { /// Starts the scheduled jobs in-process public func startScheduledJobs() throws { + guard !self.application.jobs.configuration.scheduledJobs.isEmpty else { + self.application.logger.warning("No scheduled jobs exist, exiting scheduled jobs worker.") + return + } + self.application.jobs.configuration.scheduledJobs .forEach { self.schedule($0) } }