Skip to content

Commit f770d33

Browse files
committed
LB updates
1 parent 286a7f4 commit f770d33

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

backend/src/bin/load_balancer.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ use tokio;
2222
#[derive(StructOpt)]
2323
struct Options {}
2424

25+
// Jonline Balancer of Loads (JBL) mostly just generates an NGINX configuration
26+
// from some environment variables and Kubernetes secrets, puts them in this file,
27+
// and then starts NGINX (in the foreground) with that configuration.
2528
const NGINX_CONF: &str = "nginx.conf.jbl";
2629

2730
#[tokio::main]
@@ -63,7 +66,14 @@ A Rust load balancer for Jonline servers deployed on Kubernetes
6366
} else {
6467
log::info!("Starting NGINX...");
6568
let mut nginx = match std::process::Command::new("nginx")
66-
.args(&["-c", NGINX_CONF, "-p", &pwd, "-g", "daemon off;"])
69+
.args(&[
70+
"-c",
71+
NGINX_CONF,
72+
"-p",
73+
&pwd,
74+
"-g",
75+
"daemon off; error_log /dev/stdout info;",
76+
])
6777
.spawn()
6878
{
6979
Ok(process) => process,
@@ -158,7 +168,11 @@ async fn setup_nginx_config(_options: &Options) -> io::Result<JonlineServerConfi
158168
})?;
159169

160170
fs::write(NGINX_CONF, "events {}")?;
161-
append_to_conf("http {")?;
171+
append_to_conf(
172+
"
173+
http {
174+
access_log /dev/stdout;",
175+
)?;
162176
for server in &servers {
163177
let host = &server.host;
164178
let namespace = &server.namespace;
@@ -287,7 +301,11 @@ async fn setup_nginx_config(_options: &Options) -> io::Result<JonlineServerConfi
287301
}
288302
}
289303

290-
append_to_conf("}")?;
304+
append_to_conf(
305+
"
306+
}
307+
",
308+
)?;
291309

292310
Ok(JonlineServerConfig { servers })
293311
}

0 commit comments

Comments
 (0)