-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: add the posibility to use hostname as WORKEY_ID
This is useful when using keda or other autoscalers, as they won't support assigning WORKER_IDs. Signed-off-by: Younes Khoudli <[email protected]>
- Loading branch information
Showing
1 changed file
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,14 +39,15 @@ class WorkerCommand : CliCommand { | |
private var editoastAuthorization: String? = null | ||
|
||
val WORKER_ID: String? | ||
val WORKER_ID_USE_HOSTNAME: String? | ||
val WORKER_KEY: String? | ||
val WORKER_AMQP_URI: String | ||
val WORKER_POOL: String | ||
val WORKER_REQUESTS_QUEUE: String | ||
val WORKER_ACTIVITY_EXCHANGE: String | ||
|
||
init { | ||
WORKER_ID = System.getenv("WORKER_ID") | ||
WORKER_ID_USE_HOSTNAME = System.getenv("WORKER_ID_USE_HOSTNAME") | ||
WORKER_KEY = System.getenv("WORKER_KEY") | ||
WORKER_AMQP_URI = | ||
System.getenv("WORKER_AMQP_URI") ?: "amqp://osrd:[email protected]:5672/%2f" | ||
|
@@ -55,6 +56,18 @@ class WorkerCommand : CliCommand { | |
System.getenv("WORKER_REQUESTS_QUEUE") ?: "$WORKER_POOL-req-$WORKER_KEY" | ||
WORKER_ACTIVITY_EXCHANGE = | ||
System.getenv("WORKER_ACTIVITY_EXCHANGE") ?: "$WORKER_POOL-activity-xchg" | ||
|
||
WORKER_ID = | ||
if ( | ||
WORKER_ID_USE_HOSTNAME == null || | ||
WORKER_ID_USE_HOSTNAME == "" || | ||
WORKER_ID_USE_HOSTNAME == "0" || | ||
WORKER_ID_USE_HOSTNAME.lowercase() == "false" | ||
) { | ||
System.getenv("WORKER_ID") | ||
} else { | ||
java.net.InetAddress.getLocalHost().hostName | ||
} | ||
} | ||
|
||
override fun run(): Int { | ||
|