mirror of https://github.com/mastodon/flodgatt
Add additional logging for postgres connection/server status
This commit is contained in:
parent
00cf62cd09
commit
9ec245ccdb
|
@ -19,19 +19,20 @@ const DEFAULT_REDIS_POLL_INTERVAL: u64 = 100;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref POSTGRES_ADDR: String = env::var("POSTGRES_ADDR").unwrap_or_else(|_| {
|
static ref POSTGRES_ADDR: String = env::var("POSTGRES_ADDR").unwrap_or_else(|_| {
|
||||||
let mut postgres_addr = DEFAULT_POSTGRES_ADDR.to_string();
|
warn!("No POSTGRES_ADDR env variable set; using default postgres address.");
|
||||||
postgres_addr.insert_str(11,
|
match &env::var("USER") {
|
||||||
match &env::var("USER") {
|
Err(_) => {
|
||||||
Err(_) => {
|
let addr = DEFAULT_POSTGRES_ADDR.replace("@", format!("{}@", "postgres").as_str());
|
||||||
warn!("No USER env variable set. Connecting to Postgress with default `postgres` user");
|
warn!("No USER env variable set; using default `postgres` user.\n Using postgres address: {}\n", addr);
|
||||||
"postgres"
|
addr
|
||||||
},
|
},
|
||||||
Ok(user) => {
|
Ok(user) => {
|
||||||
warn!("No POSTGRES_ADDR env variable set. Connecting to Postgress with the current user: {}", &user);
|
let addr = DEFAULT_POSTGRES_ADDR.replace("@", format!("{}@", user).as_str());
|
||||||
user
|
warn!("Connecting to postgres with current user.\n Using postgres address: {}\n", addr);
|
||||||
}
|
addr
|
||||||
});
|
}
|
||||||
postgres_addr
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
static ref REDIS_ADDR: String = env::var("REDIS_ADDR").unwrap_or_else(|_| DEFAULT_REDIS_ADDR.to_owned());
|
static ref REDIS_ADDR: String = env::var("REDIS_ADDR").unwrap_or_else(|_| DEFAULT_REDIS_ADDR.to_owned());
|
||||||
|
@ -71,6 +72,7 @@ pub fn cross_origin_resource_sharing() -> warp::filters::cors::Cors {
|
||||||
pub fn logging_and_env() {
|
pub fn logging_and_env() {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
POSTGRES_ADDR.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configure Postgres and return a connection
|
/// Configure Postgres and return a connection
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use log::{log_enabled, Level};
|
||||||
use ragequit::{
|
use ragequit::{
|
||||||
any_of, config,
|
any_of, config,
|
||||||
parse_client_request::{sse, user, ws},
|
parse_client_request::{sse, user, ws},
|
||||||
|
@ -12,6 +13,10 @@ fn main() {
|
||||||
let client_agent_sse = ClientAgent::blank();
|
let client_agent_sse = ClientAgent::blank();
|
||||||
let client_agent_ws = client_agent_sse.clone_with_shared_receiver();
|
let client_agent_ws = client_agent_sse.clone_with_shared_receiver();
|
||||||
|
|
||||||
|
if log_enabled!(Level::Warn) {
|
||||||
|
println!("Streaming server initialized and ready to accept connections");
|
||||||
|
};
|
||||||
|
|
||||||
// Server Sent Events
|
// Server Sent Events
|
||||||
//
|
//
|
||||||
// For SSE, the API requires users to use different endpoints, so we first filter based on
|
// For SSE, the API requires users to use different endpoints, so we first filter based on
|
||||||
|
|
Loading…
Reference in New Issue