summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docker-compose.yml3
-rw-r--r--opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt43
2 files changed, 45 insertions, 1 deletions
diff --git a/docker-compose.yml b/docker-compose.yml
index 55c880f8..eea638ce 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -57,6 +57,9 @@ services:
AUTH0_DOMAIN: ${OPENDC_RUNNER_AUTH0_DOMAIN}
AUTH0_CLIENT_SECRET: ${OPENDC_RUNNER_AUTH0_CLIENT_SECRET}
SENTRY_DSN: ${OPENDC_SERVER_SENTRY_DSN-}
+ OPENDC_JOB_TIMEOUT: ${OPENDC_JOB_TIMEOUT:-10}
+ OPENDC_POLL_INTERVAL: ${OPENDC_POLL_INTERVAL:-30}
+ OPENDC_HEARTBEAT_INTERVAL: ${OPENDC_HEARTBEAT_INTERVAL:-60}
JAVA_TOOL_OPTIONS: >-
-Dlog4j2.rootLogger.level=DEBUG
-Dlog4j2.logger.org.opendc.level=DEBUG
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()