fix: make SLEEP_QUEUE adaptative to number of subworkers

This commit is contained in:
Ruben Fiszel
2024-07-30 17:57:14 +02:00
parent f59046a924
commit 8c81e47564
2 changed files with 13 additions and 3 deletions
+7 -1
View File
@@ -790,6 +790,10 @@ pub async fn run_workers<R: rsmq_async::RsmqConnection + Send + Sync + Clone + '
.expect("could not create initial worker dir");
}
tracing::info!(
"Starting {num_workers} workers and SLEEP_QUEUE={}ms",
*windmill_worker::SLEEP_QUEUE
);
for i in 1..(num_workers + 1) {
let db1 = db.clone();
let instance_name = instance_name.clone();
@@ -802,7 +806,9 @@ pub async fn run_workers<R: rsmq_async::RsmqConnection + Send + Sync + Clone + '
let hostname = hostname.clone();
handles.push(tokio::spawn(async move {
tracing::info!(worker = %worker_name, "starting worker");
if num_workers > 1 {
tracing::info!(worker = %worker_name, "starting worker {i}");
}
let f = windmill_worker::run_worker(
&db1,
+6 -2
View File
@@ -287,10 +287,14 @@ lazy_static::lazy_static! {
pub static ref JOB_TOKEN: Option<String> = std::env::var("JOB_TOKEN").ok();
static ref SLEEP_QUEUE: u64 = std::env::var("SLEEP_QUEUE")
pub static ref SLEEP_QUEUE: u64 = std::env::var("SLEEP_QUEUE")
.ok()
.and_then(|x| x.parse::<u64>().ok())
.unwrap_or(DEFAULT_SLEEP_QUEUE);
.unwrap_or(DEFAULT_SLEEP_QUEUE * std::env::var("NUM_WORKERS")
.ok()
.map(|x| x.parse().ok())
.flatten()
.unwrap_or(2) / 2);
pub static ref DISABLE_NUSER: bool = std::env::var("DISABLE_NUSER")