()
| 59 | } |
| 60 | |
| 61 | pub fn main() -> io::Result<()> { |
| 62 | println!("{ASCII_BANNER}"); |
| 63 | |
| 64 | CryptoProvider::install_default(rustls::crypto::aws_lc_rs::default_provider()) |
| 65 | .expect("Cannot install rustls crypto provider"); |
| 66 | |
| 67 | // Load env variable from .env file |
| 68 | dotenv().ok(); |
| 69 | |
| 70 | // Init tracing subscriber |
| 71 | tracing_subscriber::fmt() |
| 72 | .with_env_filter(EnvFilter::from_default_env()) |
| 73 | .fmt_fields( |
| 74 | tracing_subscriber::fmt::format::debug_fn(|writer, field, value| write!(writer, "{field}: {value:?}")) |
| 75 | .delimited(", "), |
| 76 | ) |
| 77 | .with_ansi(true) |
| 78 | .with_thread_names(true) |
| 79 | .with_timer(UtcTime::rfc_3339()) |
| 80 | .init(); |
| 81 | |
| 82 | let deployed_engine_version = load_deployed_engine_version(build_info::ENGINE_VERSION, build_info::SHORT_COMMIT); |
| 83 | let engine_id = env::var("ID").unwrap_or_else(|_| generate_id().to_string()); |
| 84 | let version_file = env::var("BIN_VERSION_FILE").expect("BIN_VERSION_FILE is mandatory"); |
| 85 | let test_cluster_env_var = env::var("TEST_CLUSTER"); |
| 86 | let lib_root_dir = env::var("LIB_ROOT_DIR").unwrap_or_else(|_| "lib".to_string()); |
| 87 | let aws_apn_id = env::var("QOVERY_AWS_APN_ID").unwrap_or_else(|_| "not-set".to_string()); |
| 88 | let docker_host = env::var("DOCKER_HOST").map(|val| Url::parse(&val).unwrap()).ok(); |
| 89 | let workspace_root_dir = |
| 90 | env::var("WORKSPACE_ROOT_DIR").unwrap_or_else(|_| home_dir().unwrap().to_string_lossy().into_owned()); |
| 91 | |
| 92 | let logger: Box<dyn Logger> = Box::new(CompositeLogger::new(vec![Box::new(StdIoLogger::new())])); |
| 93 | let metrics_registry = Box::new(StdMetricsRegistry::new(Box::new(StdMsgPublisher::new()))); |
| 94 | |
| 95 | info!("engine id: {}", engine_id.as_str()); |
| 96 | info!("engine version : {}", deployed_engine_version); |
| 97 | info!( |
| 98 | "running from current directory: {}", |
| 99 | env::current_dir().unwrap().to_str().unwrap() |
| 100 | ); |
| 101 | info!("lib root dir: {}/", lib_root_dir.as_str()); |
| 102 | info!("workspace root dir: {}", workspace_root_dir.as_str()); |
| 103 | |
| 104 | match check_libs_directory(lib_root_dir.clone()) { |
| 105 | Ok(_) => info!("Libs directory is not empty"), |
| 106 | Err(e) => { |
| 107 | error!("Error while initializing the Engine {}", e); |
| 108 | process::exit(1); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | //checking if version file exist |
| 113 | match Path::new(&version_file).exists() { |
| 114 | true => info!("Version file is accessible"), |
| 115 | _ => { |
| 116 | error!("Error while initializing the Engine, version file is not accessible"); |
| 117 | process::exit(1); |
| 118 | } |
nothing calls this directly
no test coverage detected