From 263e03c2bd508dd94ae6f30fd4cbc67b416b7ef4 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 12 Jun 2023 12:00:42 +0200 Subject: [PATCH] feat: remove the need for BASE_INTERNAL_URL --- README.md | 1 - backend/src/main.rs | 37 ++++++++++++++++-------------- backend/windmill-common/src/lib.rs | 2 +- docker-compose.yml | 3 +-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 34e807cdf3..dfd0de6a5f 100644 --- a/README.md +++ b/README.md @@ -315,7 +315,6 @@ it being synced automatically everyday. | METRICS_ADDR | None | The socket addr at which to expose Prometheus metrics at the /metrics path. Set to "true" to expose it on port 8001 | All | | JSON_FMT | false | Output the logs in json format instead of logfmt | All | | BASE_URL | http://localhost:8000 | The base url that is exposed publicly to access your instance | Server | -| BASE_INTERNAL_URL | http://localhost:8000 | The base url that is reachable by your workers to talk to the Servers. This help avoiding going through the external load balancer for VPC-internal requests. | Worker | | TIMEOUT | 300 | The maximum time of execution of a script. When reached, the job is failed as having timedout. | Worker | | ZOMBIE_JOB_TIMEOUT | 30 | The timeout after which a job is considered to be zombie if the worker did not send pings about processing the job (every server check for zombie jobs every 30s) | Server | | RESTART_ZOMBIE_JOBS | true | If true then a zombie job is restarted (in-place with the same uuid and some logs), if false the zombie job is failed | Server | diff --git a/backend/src/main.rs b/backend/src/main.rs index dd29cdd6ef..295216ef63 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -47,22 +47,30 @@ async fn main() -> anyhow::Result<()> { let metrics_addr: Option = *METRICS_ADDR; - let server_bind_address: IpAddr = std::env::var("SERVER_BIND_ADDR") + let server_mode = !std::env::var("DISABLE_SERVER") .ok() - .and_then(|x| x.parse().ok()) - .unwrap_or(IpAddr::from(DEFAULT_SERVER_BIND_ADDR)); + .and_then(|x| x.parse::().ok()) + .unwrap_or(false); + + let server_bind_address: IpAddr = if server_mode { + std::env::var("SERVER_BIND_ADDR") + .ok() + .and_then(|x| x.parse().ok()) + .unwrap_or(IpAddr::from(DEFAULT_SERVER_BIND_ADDR)) + } else { + IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)) + }; let port: u16 = std::env::var("PORT") .ok() .and_then(|x| x.parse::().ok()) .unwrap_or(DEFAULT_PORT as u16); - let base_internal_url: String = std::env::var("BASE_INTERNAL_URL") - .unwrap_or_else(|_| format!("http://localhost:{}", port.to_string())); - let server_mode = !std::env::var("DISABLE_SERVER") - .ok() - .and_then(|x| x.parse::().ok()) - .unwrap_or(false); + if std::env::var("BASE_INTERNAL_URL").is_ok() { + tracing::warn!("BASE_INTERNAL_URL is now unecessary and ignored, you can remove it."); + } + + let base_internal_url: String = format!("http://localhost:{}", port.to_string()); let rsmq_config = std::env::var("REDIS_URL").ok().map(|x| { let url = x.parse::().unwrap(); @@ -100,10 +108,8 @@ async fn main() -> anyhow::Result<()> { None }; - if server_mode { - // migration code to avoid break - windmill_api::migrate_db(&db).await?; - } + // migration code to avoid break + windmill_api::migrate_db(&db).await?; let (tx, rx) = tokio::sync::broadcast::channel::<()>(3); let shutdown_signal = windmill_common::shutdown_signal(tx.clone(), rx.resubscribe()); @@ -131,7 +137,6 @@ Windmill Community Edition {GIT_VERSION} "METRICS_ADDR", "JSON_FMT", "BASE_URL", - "BASE_INTERNAL_URL", "TIMEOUT", "ZOMBIE_JOB_TIMEOUT", "RESTART_ZOMBIE_JOBS", @@ -183,9 +188,7 @@ Windmill Community Edition {GIT_VERSION} let rsmq2 = rsmq.clone(); let server_f = async { - if server_mode { - windmill_api::run_server(db.clone(), rsmq2, addr, rx.resubscribe()).await?; - } + windmill_api::run_server(db.clone(), rsmq2, addr, rx.resubscribe()).await?; Ok(()) as anyhow::Result<()> }; diff --git a/backend/windmill-common/src/lib.rs b/backend/windmill-common/src/lib.rs index 3d95b64086..aafc2b8d7e 100644 --- a/backend/windmill-common/src/lib.rs +++ b/backend/windmill-common/src/lib.rs @@ -28,7 +28,7 @@ pub mod variables; pub mod tracing_init; pub const DEFAULT_MAX_CONNECTIONS_SERVER: u32 = 50; -pub const DEFAULT_MAX_CONNECTIONS_WORKER: u32 = 3; +pub const DEFAULT_MAX_CONNECTIONS_WORKER: u32 = 5; lazy_static::lazy_static! { pub static ref METRICS_ADDR: Option = std::env::var("METRICS_ADDR") diff --git a/docker-compose.yml b/docker-compose.yml index 3fca8043b1..f1e66c2778 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - DATABASE_URL=postgres://postgres:${DB_PASSWORD}@db/windmill?sslmode=disable - BASE_URL=${WM_BASE_URL} - RUST_LOG=info - ## You can set the number of workers to > 0 and not need any separate worker service + ## You can set the number of workers to > 0 and not need any separate worker service but not recommended - NUM_WORKERS=0 - DISABLE_SERVER=false - METRICS_ADDR=false @@ -50,7 +50,6 @@ services: environment: - DATABASE_URL=postgres://postgres:${DB_PASSWORD}@db/windmill?sslmode=disable - BASE_URL=${WM_BASE_URL} - - BASE_INTERNAL_URL=http://windmill_server:8000 - RUST_LOG=info - NUM_WORKERS=1 - DISABLE_SERVER=true