chore: add AppStore, AppDataConn & check datastores

This commit is contained in:
Jesús Pérez Lorenzo 2021-09-19 23:18:54 +01:00
parent 2574068505
commit 6864cd3092

View File

@ -1,4 +1,6 @@
// use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio_cron_scheduler::{JobScheduler, Job};
pub type BxDynResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
use app_env::{
@ -9,6 +11,7 @@ use app_env::{
config::{Config}
};
use clds::monitor::defs::MonitorRules;
use connectors::defs::{AppDataConn};
use app_auth::AuthStore;
use reject_filters::{handle_rejection};
use anyhow::{anyhow,Result};
@ -88,10 +91,12 @@ async fn up_web_server(webpos: usize) -> Result<()> {
if verbose > 0 {
println!("Load data store ...");
}
let app_data_conn = AppDataConn::new("Zterton".to_string(),app_env.config.datastores_settings.to_owned(),"").await;
let data_dbs = DataDBs {
colls: CollsData::new(app_env.to_owned(),verbose),
app: app_store.to_owned(),
auth: auth_store.to_owned(),
conns: Arc::new(Mutex::from(app_data_conn)),
};
if verbose > 0 {
println!("Load web filters ...");
@ -320,6 +325,10 @@ pub async fn main() -> BxDynResult<()> { //std::io::Result<()> {
panic!("Error no run_mode found or config path incomplete");
}
let config = Config::new(config_content,debug);
let app_data_conn = AppDataConn::new("Zterton".to_string(),config.datastores_settings.to_owned(),"").await;
if !app_data_conn.check_connections(config.datastores_settings.to_owned()).await {
panic!("Error checking app data store connections");
}
if config.run_schedtasks {
for it in &config.schedtasks {
if ! it.on_start {