diff options
| author | vincent van beek <vincent@vlogic.nl> | 2026-04-03 13:02:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-03 12:02:59 +0100 |
| commit | d7685a0a11d196890f9a0d6fdccbba34e39a8885 (patch) | |
| tree | 00c26e5b970add055c0c9f0692fb04178fba15de /opendc-web/opendc-web-runner/src/cli | |
| parent | 61cf5ddfaf57c520428685768ba4a0ba31fda5f3 (diff) | |
add configuration options for JOB_TIMEOUT, POLL_INTERVAL and HEARTBEA… (#402)
* add configuration options for JOB_TIMEOUT, POLL_INTERVAL and HEARTBEAT_INTERVAL
* fix ./gradlew :opendc-web:opendc-web-runner:spotlessApply
Diffstat (limited to 'opendc-web/opendc-web-runner/src/cli')
| -rw-r--r-- | opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt | 43 |
1 files changed, 42 insertions, 1 deletions
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() |
