you cant do a runtime in a drop like this apparently

This commit is contained in:
Bryan Stitt 2023-07-14 01:19:09 -07:00
parent 6371206315
commit 37e3d0be2b
2 changed files with 1 additions and 20 deletions

@ -166,26 +166,6 @@ pub struct Web3ProxyAppSpawn {
pub ranked_rpcs: watch::Receiver<Option<Arc<RankedRpcs>>>,
}
impl Drop for Web3ProxyApp {
fn drop(&mut self) {
if let Ok(db_conn) = self.db_conn().cloned() {
/*
From the sqlx docs:
We recommend calling .close().await to gracefully close the pool and its connections when you are done using it.
This will also wake any tasks that are waiting on an .acquire() call,
so for long-lived applications its a good idea to call .close() during shutdown.
*/
let rt = Runtime::new().unwrap();
if let Err(err) = rt.block_on(db_conn.close()) {
error!(?err, "Unable to close db!");
};
}
}
}
impl Web3ProxyApp {
/// The main entrypoint.
pub async fn spawn(

@ -615,6 +615,7 @@ impl Web3ProxyError {
)
}
Self::NoDatabase => {
// TODO: this needs more context
error!("no database configured");
(
StatusCode::INTERNAL_SERVER_ERROR,