Aligning the different parts with the new directory and file structure.
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
parent
67da992326
commit
399fe1d549
@ -9,6 +9,7 @@
|
||||
# Get all services on the server
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
|
||||
# //------------------------------------------------------------------------------------------------
|
||||
# // remote paths
|
||||
# // DROPSHELL_DIR
|
||||
# // |-- backups
|
||||
@ -19,17 +20,19 @@ SCRIPT_DIR="$(dirname "$0")"
|
||||
# // |-- services
|
||||
# // |-- service name
|
||||
# // |-- config
|
||||
# // |-- service.env
|
||||
# // |-- service.env (actual service config)
|
||||
# // |-- .template_info.env
|
||||
# // |-- template
|
||||
# // |-- _default.env
|
||||
# // |-- (script files)
|
||||
# // |-- config
|
||||
# // |-- service.env
|
||||
# // |-- service.env (default service config)
|
||||
# // |-- .template_info.env
|
||||
# // |-- (other config files for specific server&service)
|
||||
|
||||
# Get all services on the server
|
||||
SERVICES_PATH=$(realpath "${SCRIPT_DIR}/../services/")
|
||||
|
||||
|
||||
CURRENT_OUTPUT=""
|
||||
CURRENT_EXIT_CODE=0
|
||||
|
||||
@ -40,6 +43,15 @@ load_dotenv(){
|
||||
fi
|
||||
}
|
||||
|
||||
_check_required_env_vars_allservicesstatus() {
|
||||
local required_vars=("$@")
|
||||
for var in "${required_vars[@]}"; do
|
||||
if [ -z "${!var}" ]; then
|
||||
_die "Required environment variable $var is not set"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
local service_path=$1
|
||||
local command=$2
|
||||
@ -55,12 +67,22 @@ function run_command() {
|
||||
set -a
|
||||
load_dotenv "${service_path}/template/_default.env"
|
||||
load_dotenv "${service_path}/config/service.env"
|
||||
load_dotenv "${service_path}/config/.template_info.env"
|
||||
set +a
|
||||
|
||||
# all_env_vars["CONFIG_PATH"] = remotepath::service_config(server_name,service_name);
|
||||
# all_env_vars["SERVER"] = server_name;
|
||||
# all_env_vars["SERVICE"] = service_name;
|
||||
# all_env_vars["AGENT_PATH"] = remotepath::agent(server_name);
|
||||
# all_env_vars["HOST_NAME"] = server_info.ssh_host;
|
||||
# update the main variables.
|
||||
export CONFIG_PATH="${service_path}/config"
|
||||
# SERVER is correct
|
||||
# SERVER is already set
|
||||
export SERVICE="${SERVICE_NAME}"
|
||||
export AGENT_PATH="${SCRIPT_DIR}"
|
||||
# HOST_NAME is already set
|
||||
|
||||
_check_required_env_vars_allservicesstatus "CONFIG_PATH" "SERVER" "SERVICE" "AGENT_PATH" "HOST_NAME" "TEMPLATE"
|
||||
|
||||
if [ "$capture_output" = "true" ]; then
|
||||
# Capture and return output
|
||||
|
@ -182,7 +182,7 @@ std::map<std::string, ServiceStatus> service_runner::get_all_services_status(std
|
||||
}
|
||||
|
||||
std::string output;
|
||||
if (!execute_ssh_command(env.get_SSH_INFO(), sCommand(remotepath::agent(server_name), "./_allservicesstatus.sh", {}), cMode::CaptureOutput, &output))
|
||||
if (!execute_ssh_command(env.get_SSH_INFO(), sCommand(remotepath::agent(server_name), "./_allservicesstatus.sh", {{"HOST_NAME", server_name}}), cMode::CaptureOutput, &output))
|
||||
return status;
|
||||
|
||||
std::stringstream ss(output);
|
||||
|
@ -225,15 +225,17 @@ bool get_all_service_env_vars(const std::string &server_name, const std::string
|
||||
return false;
|
||||
}
|
||||
|
||||
ServerInfo server_info = get_server_info(server_name);
|
||||
if (server_info.ssh_host.empty())
|
||||
std::cerr << "Error: Server " << server_name << " not found - ssh_host empty, so HOST_NAME not set" << std::endl;
|
||||
|
||||
|
||||
// add in some handy variables.
|
||||
// if we change these, we also need to update agent/_allservicesstatus.sh
|
||||
all_env_vars["CONFIG_PATH"] = remotepath::service_config(server_name,service_name);
|
||||
all_env_vars["SERVER"] = server_name;
|
||||
all_env_vars["SERVICE"] = service_name;
|
||||
all_env_vars["AGENT_PATH"] = remotepath::agent(server_name);
|
||||
|
||||
ServerInfo server_info = get_server_info(server_name);
|
||||
if (server_info.ssh_host.empty())
|
||||
std::cerr << "Error: Server " << server_name << " not found - ssh_host empty, so HOST_NAME not set" << std::endl;
|
||||
all_env_vars["HOST_NAME"] = server_info.ssh_host;
|
||||
|
||||
// Lambda function to load environment variables from a file
|
||||
|
@ -83,23 +83,27 @@ namespace localpath {
|
||||
}
|
||||
} // namespace localpath
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// remote paths
|
||||
// DROPSHELL_DIR
|
||||
// |-- backups
|
||||
// |-- temp_files
|
||||
// |-- agent
|
||||
// | |-- bb64
|
||||
// | |-- (other agent files, including _allservicesstatus.sh)
|
||||
// |-- services
|
||||
// |-- service name
|
||||
// |-- config
|
||||
// |-- service.env
|
||||
// |-- service.env (actual service config)
|
||||
// |-- template
|
||||
// |-- _default.env
|
||||
// |-- (script files)
|
||||
// |-- config
|
||||
// |-- service.env
|
||||
// |-- service.env (default service config)
|
||||
// |-- (other config files for specific server&service)
|
||||
|
||||
|
||||
|
||||
namespace remotefile {
|
||||
|
||||
std::string service_env(const std::string &server_name, const std::string &service_name)
|
||||
|
@ -76,11 +76,14 @@ namespace dropshell {
|
||||
// |-- services
|
||||
// |-- service name
|
||||
// |-- config
|
||||
// |-- service.env
|
||||
// |-- service.env (actual service config)
|
||||
// |-- .template_info.env
|
||||
// |-- template
|
||||
// |-- _default.env
|
||||
// |-- (script files)
|
||||
// |-- config
|
||||
// |-- service.env
|
||||
// |-- service.env (default service config)
|
||||
// |-- .template_info.env
|
||||
// |-- (other config files for specific server&service)
|
||||
|
||||
namespace remotefile {
|
||||
|
Loading…
x
Reference in New Issue
Block a user