mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 18:36:28 +00:00
Exit with failure codes if configs are bad (#146)
* Exit with failure codes if configs are bad * fmt
This commit is contained in:
committed by
GitHub
parent
9d84d6f131
commit
3bc4f9351c
@@ -3,6 +3,9 @@
|
|||||||
set -e
|
set -e
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
|
# non-zero exit code if we provide bad configs
|
||||||
|
(! ./target/debug/pgcat "fake_configs" 2>/dev/null)
|
||||||
|
|
||||||
# Start PgCat with a particular log level
|
# Start PgCat with a particular log level
|
||||||
# for inspection.
|
# for inspection.
|
||||||
function start_pgcat() {
|
function start_pgcat() {
|
||||||
|
|||||||
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -159,6 +159,12 @@ dependencies = [
|
|||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "exitcode"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
@@ -515,6 +521,7 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"exitcode",
|
||||||
"hmac",
|
"hmac",
|
||||||
"hyper",
|
"hyper",
|
||||||
"log",
|
"log",
|
||||||
|
|||||||
@@ -33,3 +33,4 @@ tokio-rustls = "0.23"
|
|||||||
rustls-pemfile = "1"
|
rustls-pemfile = "1"
|
||||||
hyper = { version = "0.14", features = ["full"] }
|
hyper = { version = "0.14", features = ["full"] }
|
||||||
phf = { version = "0.10", features = ["macros"] }
|
phf = { version = "0.10", features = ["macros"] }
|
||||||
|
exitcode = "1.1.2"
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -24,6 +24,7 @@ extern crate async_trait;
|
|||||||
extern crate bb8;
|
extern crate bb8;
|
||||||
extern crate bytes;
|
extern crate bytes;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
|
extern crate exitcode;
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate md5;
|
extern crate md5;
|
||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
@@ -78,7 +79,7 @@ async fn main() {
|
|||||||
|
|
||||||
if !query_router::QueryRouter::setup() {
|
if !query_router::QueryRouter::setup() {
|
||||||
error!("Could not setup query router");
|
error!("Could not setup query router");
|
||||||
return;
|
std::process::exit(exitcode::CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = std::env::args().collect::<Vec<String>>();
|
let args = std::env::args().collect::<Vec<String>>();
|
||||||
@@ -93,7 +94,7 @@ async fn main() {
|
|||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Config parse error: {:?}", err);
|
error!("Config parse error: {:?}", err);
|
||||||
return;
|
std::process::exit(exitcode::CONFIG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ async fn main() {
|
|||||||
Ok(addr) => addr,
|
Ok(addr) => addr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Invalid http address: {}", err);
|
error!("Invalid http address: {}", err);
|
||||||
return;
|
std::process::exit(exitcode::CONFIG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
@@ -122,7 +123,7 @@ async fn main() {
|
|||||||
Ok(sock) => sock,
|
Ok(sock) => sock,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Listener socket error: {:?}", err);
|
error!("Listener socket error: {:?}", err);
|
||||||
return;
|
std::process::exit(exitcode::CONFIG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ async fn main() {
|
|||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Pool error: {:?}", err);
|
error!("Pool error: {:?}", err);
|
||||||
return;
|
std::process::exit(exitcode::CONFIG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user