Start roughing out K8s deployment spec for api-server; bootstrap global locks AFTER DB migrations have run
This commit is contained in:
@@ -7,7 +7,6 @@ use sea_orm_rocket::{Config, Database, Pool};
|
||||
use async_trait::async_trait;
|
||||
use rocket::fairing::AdHoc;
|
||||
use sea_orm::ConnectOptions;
|
||||
use crate::api::entity::locks::ensure_vmid_lock;
|
||||
|
||||
#[derive(Database, Debug)]
|
||||
#[database("p5x_api")]
|
||||
@@ -43,8 +42,6 @@ impl Pool for DbPool {
|
||||
|
||||
let conn = sea_orm::Database::connect(options).await?;
|
||||
|
||||
ensure_vmid_lock(&conn).await?; // todo: probably a better place to put this
|
||||
|
||||
Ok(DbPool { conn })
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,22 @@ mod route;
|
||||
pub mod util;
|
||||
pub mod cluster;
|
||||
pub mod entity;
|
||||
pub use db::Db;
|
||||
use sea_orm_rocket::Database;
|
||||
use db::Db;
|
||||
use crate::api::entity::locks::ensure_vmid_lock;
|
||||
|
||||
pub mod services;
|
||||
|
||||
/** Perform any init-time operations that require the DB. */
|
||||
pub fn post_init() -> AdHoc {
|
||||
AdHoc::on_ignite("post_init", |rocket| async {
|
||||
let conn = &Db::fetch(&rocket).unwrap().conn;
|
||||
ensure_vmid_lock(&conn).await.unwrap();
|
||||
|
||||
rocket
|
||||
})
|
||||
}
|
||||
|
||||
pub fn init() -> AdHoc {
|
||||
AdHoc::on_ignite("mod(db)", |rocket| async {
|
||||
rocket.attach(db::init())
|
||||
|
||||
Reference in New Issue
Block a user