diff --git a/Cargo.toml b/Cargo.toml index 7118735..8dbc988 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ features = ["http1", "server"] [dependencies.tokio] version = "1.27" default-features = false -features = ["macros", "rt-multi-thread", "signal"] +features = ["macros", "rt-multi-thread", "signal", "time"] [profile.release] lto = true diff --git a/src/main.rs b/src/main.rs index cd98869..82373b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,8 +30,17 @@ fn main() -> anyhow::Result<()> { }; runtime.block_on(async { + let (client, connection) = loop { + // HACK: Railway Private Networking requires 100ms to set up. + let err = match config.connect(api::NoTls).await { + Ok(pair) => break pair, + Err(err) => err, + }; + log::error!("{err}"); + tokio::time::sleep(core::time::Duration::from_secs(1)).await; + }; + use core::pin::pin; - let (client, connection) = config.connect(api::NoTls).await?; let mut postgres = pin!(runtime.spawn(connection)); log::info!("PostgreSQL driver connected");