From d7685a0a11d196890f9a0d6fdccbba34e39a8885 Mon Sep 17 00:00:00 2001 From: vincent van beek Date: Fri, 3 Apr 2026 13:02:59 +0200 Subject: =?UTF-8?q?add=20configuration=20options=20for=20JOB=5FTIMEOUT,=20?= =?UTF-8?q?POLL=5FINTERVAL=20and=20HEARTBEA=E2=80=A6=20(#402)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add configuration options for JOB_TIMEOUT, POLL_INTERVAL and HEARTBEAT_INTERVAL * fix ./gradlew :opendc-web:opendc-web-runner:spotlessApply --- .../src/cli/kotlin/org/opendc/web/runner/Main.kt | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'opendc-web') diff --git a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt index 6583810c..6271cdf2 100644 --- a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt +++ b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt @@ -119,6 +119,39 @@ class RunnerCli : CliktCommand(name = "opendc-runner") { .int() .default(Runtime.getRuntime().availableProcessors() - 1) + /** + * The maximum duration of a simulation job in minutes. + */ + private val jobTimeout by option( + "--job-timeout", + help = "maximum duration of a simulation job in minutes", + envvar = "OPENDC_JOB_TIMEOUT", + ) + .int() + .default(10) + + /** + * The interval to poll the API for new jobs in seconds. + */ + private val pollInterval by option( + "--poll-interval", + help = "interval to poll the API for new jobs in seconds", + envvar = "OPENDC_POLL_INTERVAL", + ) + .int() + .default(30) + + /** + * The interval to send a heartbeat to the API server in seconds. + */ + private val heartbeatInterval by option( + "--heartbeat-interval", + help = "interval to send a heartbeat to the API server in seconds", + envvar = "OPENDC_HEARTBEAT_INTERVAL", + ) + .int() + .default(60) + override fun run() { logger.info { "Starting OpenDC web runner" } @@ -148,7 +181,15 @@ class RunnerCli : CliktCommand(name = "opendc-runner") { val client = OpenDCRunnerClient(baseUrl = apiUrl, authController) val manager = JobManager(client) - val runner = OpenDCRunner(manager, tracePath, parallelism = parallelism) + val runner = + OpenDCRunner( + manager, + tracePath, + parallelism = parallelism, + jobTimeout = java.time.Duration.ofMinutes(jobTimeout.toLong()), + pollInterval = java.time.Duration.ofSeconds(pollInterval.toLong()), + heartbeatInterval = java.time.Duration.ofSeconds(heartbeatInterval.toLong()), + ) logger.info { "Watching for queued scenarios" } runner.run() -- cgit v1.2.3