chore: startup logging polish; BIND_PORT env var setting added
This commit is contained in:
parent
4cf3d5aea0
commit
594e91b8a1
6 changed files with 40 additions and 33 deletions
52
Cargo.lock
generated
52
Cargo.lock
generated
|
|
@ -940,6 +940,32 @@ dependencies = [
|
|||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mc-ingress"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"either",
|
||||
"futures",
|
||||
"k8s-openapi",
|
||||
"kube",
|
||||
"nix",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"strip-ansi-escapes",
|
||||
"tokio",
|
||||
"tokio-splice2",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"tracing-error",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
|
|
@ -1143,32 +1169,6 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-start"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"either",
|
||||
"futures",
|
||||
"k8s-openapi",
|
||||
"kube",
|
||||
"nix",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"strip-ansi-escapes",
|
||||
"tokio",
|
||||
"tokio-splice2",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"tracing-error",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.42"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "quick-start"
|
||||
name = "mc-ingress"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
|
|
|||
2
README.md
Normal file
2
README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Env variables:
|
||||
- BIND_PORT(default: 25565): the port the server should bind to
|
||||
2
build.rs
2
build.rs
|
|
@ -13,5 +13,5 @@ fn main() {
|
|||
}
|
||||
}
|
||||
};
|
||||
println!("cargo::rustc-env=COMMIT_HASH=\"{}\"", commit_hash);
|
||||
println!("cargo::rustc-env=COMMIT_HASH={}", commit_hash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
# Additional environment variables can be set directly
|
||||
# MY_CUSTOM_VAR = "some value";
|
||||
COMMIT_HASH = builtins.substring 0 7 (
|
||||
if self ? rev then self.rev else "nixDirt"
|
||||
if self ? rev then self.rev else "NoDHash"
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
13
src/main.rs
13
src/main.rs
|
|
@ -1,3 +1,4 @@
|
|||
use std::env;
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
|
||||
use futures::TryFutureExt;
|
||||
|
|
@ -30,15 +31,19 @@ async fn main() {
|
|||
.with(tracing_error::ErrorLayer::default())
|
||||
.init();
|
||||
|
||||
let commit_hash: &'static str = env!("COMMIT_HASH");
|
||||
tracing::info!("revision: {}", commit_hash);
|
||||
let revision: &'static str = env!("COMMIT_HASH");
|
||||
tracing::info!(revision);
|
||||
|
||||
let cache = kube_cache::Cache::create().unwrap();
|
||||
let arc_cache = Arc::new(Mutex::new(cache));
|
||||
tracing::info!("initialized kube api");
|
||||
|
||||
let listener = TcpListener::bind("0.0.0.0:25565").await.unwrap();
|
||||
tracing::info!("started tcp server");
|
||||
let port = match env::var("BIND_PORT") {
|
||||
Ok(x) => x,
|
||||
Err(_) => "25565".to_string(),
|
||||
};
|
||||
let listener = TcpListener::bind(format!("0.0.0.0:{port}")).await.unwrap();
|
||||
tracing::info!(port, "started tcp server");
|
||||
|
||||
loop {
|
||||
let (socket, addr) = listener.accept().await.unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue