Skip to content

Exit with failure codes if configs are bad #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -e
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
# for inspection.
function start_pgcat() {
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ tokio-rustls = "0.23"
rustls-pemfile = "1"
hyper = { version = "0.14", features = ["full"] }
phf = { version = "0.10", features = ["macros"] }
exitcode = "1.1.2"
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern crate async_trait;
extern crate bb8;
extern crate bytes;
extern crate env_logger;
extern crate exitcode;
extern crate log;
extern crate md5;
extern crate num_cpus;
Expand Down Expand Up @@ -77,7 +78,7 @@ async fn main() {

if !query_router::QueryRouter::setup() {
error!("Could not setup query router");
return;
std::process::exit(exitcode::CONFIG);
}

let args = std::env::args().collect::<Vec<String>>();
Expand All @@ -92,7 +93,7 @@ async fn main() {
Ok(_) => (),
Err(err) => {
error!("Config parse error: {:?}", err);
return;
std::process::exit(exitcode::CONFIG);
}
};

Expand All @@ -107,7 +108,7 @@ async fn main() {
Ok(addr) => addr,
Err(err) => {
error!("Invalid http address: {}", err);
return;
std::process::exit(exitcode::CONFIG);
}
};
tokio::task::spawn(async move {
Expand All @@ -121,7 +122,7 @@ async fn main() {
Ok(sock) => sock,
Err(err) => {
error!("Listener socket error: {:?}", err);
return;
std::process::exit(exitcode::CONFIG);
}
};

Expand All @@ -141,7 +142,7 @@ async fn main() {
Ok(_) => (),
Err(err) => {
error!("Pool error: {:?}", err);
return;
std::process::exit(exitcode::CONFIG);
}
};

Expand Down