Split scheduled jobs so the working open-data fetch can run without the credential-less FTP/Harmonie jobs crash-looping the app
This commit is contained in:
@@ -55,11 +55,25 @@ object Main extends IOApp {
|
||||
server <- Server.of(postgresService, dataService, fetchLvgmcService, warningService)
|
||||
serverTask = server.run
|
||||
|
||||
scheduledTasks =
|
||||
// Split from the legacy provider jobs below: parMapN cancels and fails
|
||||
// every branch the moment any one of them throws, and the FTP/Harmonie
|
||||
// paths currently point at placeholder credentials that always throw
|
||||
// on first use. Without this split, enabling scheduled jobs at all
|
||||
// would crash-loop the whole app (server included) roughly every few
|
||||
// minutes rather than just start the real, working open-data fetch.
|
||||
safeTasks =
|
||||
if (sys.env.get("ENABLE_SCHEDULED_JOBS").exists(_.equalsIgnoreCase("false")))
|
||||
IO.never[Unit]
|
||||
else
|
||||
(fetchStationsTask, fetchOpenDataStationsTask, cleanupTask, fetchGribTask).parMapN((_, _, _, _) => ())
|
||||
(fetchOpenDataStationsTask, cleanupTask).parMapN((_, _) => ())
|
||||
|
||||
legacyProviderTasks =
|
||||
if (sys.env.get("ENABLE_LEGACY_PROVIDER_JOBS").exists(_.equalsIgnoreCase("true")))
|
||||
(fetchStationsTask, fetchGribTask).parMapN((_, _) => ())
|
||||
else
|
||||
IO.never[Unit]
|
||||
|
||||
scheduledTasks = (safeTasks, legacyProviderTasks).parMapN((_, _) => ())
|
||||
|
||||
exitCode <- (serverTask, scheduledTasks).parMapN((_, _) => ExitCode.Success)
|
||||
} yield exitCode
|
||||
|
||||
Reference in New Issue
Block a user