Add testcontainer for agent image with nginx
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
pub mod agent;
|
||||
pub mod db;
|
||||
mod env;
|
||||
pub mod types;
|
||||
mod util;
|
||||
|
||||
use crate::{
|
||||
agent::AgentConfigInfoType,
|
||||
db::DBConfigInfoType,
|
||||
types::{ConfigInfoType, WithContainer, WithoutContainer},
|
||||
util::{
|
||||
@@ -15,6 +17,7 @@ use crate::{
|
||||
#[derive(Clone)]
|
||||
pub struct Config {
|
||||
pub database: DBConfigInfoType,
|
||||
pub agent: Option<AgentConfigInfoType>,
|
||||
}
|
||||
|
||||
// relative to the pwd
|
||||
@@ -56,26 +59,29 @@ impl<'a> Drop for DetachedHandle<'a> {
|
||||
}
|
||||
|
||||
async fn start(config: &Config) {
|
||||
let db_config = &config.database;
|
||||
//
|
||||
// write the config files for the api server and database client
|
||||
println!("Writing config files...");
|
||||
write_env_files(db_config);
|
||||
write_env_files(&config.database, &config.agent);
|
||||
println!("Config files written to:");
|
||||
println!(" - {}", to_absolute_path(API_CONFIG_PATH).display());
|
||||
println!(" - {}", to_absolute_path(DB_CONFIG_PATH).display());
|
||||
}
|
||||
|
||||
async fn stop(config: &Config) {
|
||||
let db_config = &config.database;
|
||||
// stop the container
|
||||
println!("Stopping container...");
|
||||
stop_container(db_config, "database".to_string()).await;
|
||||
println!("Stopping database container...");
|
||||
stop_container(&config.database, "database".to_string()).await;
|
||||
if let Some(agent) = &config.agent {
|
||||
println!("Stopping agent container...");
|
||||
stop_container(agent, "agent".to_string()).await;
|
||||
}
|
||||
println!("Container stopped.");
|
||||
// remove the generated config file
|
||||
println!("Removing generated config file...");
|
||||
remove_file_if_exists(DB_CONFIG_PATH);
|
||||
remove_file_if_exists(API_CONFIG_PATH);
|
||||
println!("Container stopped.");
|
||||
println!("Generated config files removed.");
|
||||
}
|
||||
|
||||
pub async fn start_attached(config: &Config) {
|
||||
|
||||
Reference in New Issue
Block a user