getting there
This commit is contained in:
parent
39e53ccb11
commit
a517940310
@ -212,7 +212,7 @@ int main(int argc, char* argv[]) {
|
|||||||
// handle running a command.
|
// handle running a command.
|
||||||
std::set<std::string> commands;
|
std::set<std::string> commands;
|
||||||
dropshell::get_all_used_commands(commands);
|
dropshell::get_all_used_commands(commands);
|
||||||
commands.merge(std::set<std::string>{"ssh","edit"}); // handled by service_runner, but not in template_shell_commands.
|
commands.merge(std::set<std::string>{"ssh","edit","_allservicesstatus"}); // handled by service_runner, but not in template_shell_commands.
|
||||||
for (const auto& command : commands) {
|
for (const auto& command : commands) {
|
||||||
if (cmd == command) {
|
if (cmd == command) {
|
||||||
std::string server_name;
|
std::string server_name;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -x
|
|
||||||
|
|
||||||
# This script checks ALL services on the server and returns a status for each.
|
# This script checks ALL services on the server and returns a status for each.
|
||||||
|
|
||||||
@ -22,6 +21,16 @@ SCRIPT_DIR="$(dirname "$0")"
|
|||||||
# // |-- service.env
|
# // |-- service.env
|
||||||
# // |-- (other config files for specific server&service)
|
# // |-- (other config files for specific server&service)
|
||||||
|
|
||||||
|
CURRENT_OUTPUT=""
|
||||||
|
CURRENT_EXIT_CODE=0
|
||||||
|
|
||||||
|
load_dotenv(){
|
||||||
|
local file_path=$1
|
||||||
|
if [ -f "${file_path}" ]; then
|
||||||
|
source <("${file_path}" | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function run_command() {
|
function run_command() {
|
||||||
local service_path=$1
|
local service_path=$1
|
||||||
local command=$2
|
local command=$2
|
||||||
@ -33,8 +42,11 @@ function run_command() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run the command in a subshell to prevent environment changes
|
# run the command in a subshell to prevent environment changes
|
||||||
(
|
CURRENT_OUTPUT=$(
|
||||||
source "${service_path}/config/service.env"
|
set -a
|
||||||
|
load_dotenv "${service_path}/template/_default.env"
|
||||||
|
load_dotenv "${service_path}/config/service.env"
|
||||||
|
set +a
|
||||||
|
|
||||||
# update the main variables.
|
# update the main variables.
|
||||||
export CONFIG_PATH="${service_path}/config"
|
export CONFIG_PATH="${service_path}/config"
|
||||||
@ -43,16 +55,15 @@ function run_command() {
|
|||||||
|
|
||||||
if [ "$capture_output" = "true" ]; then
|
if [ "$capture_output" = "true" ]; then
|
||||||
# Capture and return output
|
# Capture and return output
|
||||||
CURRENT_OUTPUT=$(bash "${service_path}/template/${command}.sh" 2>&1)
|
bash "${service_path}/template/${command}.sh" 2>&1
|
||||||
CURRENT_EXIT_CODE=$?
|
|
||||||
else
|
else
|
||||||
# Run silently and return exit code
|
# Run silently and return exit code
|
||||||
bash "${service_path}/template/${command}.sh" > /dev/null 2>&1
|
bash "${service_path}/template/${command}.sh" > /dev/null 2>&1
|
||||||
CURRENT_OUTPUT=""
|
|
||||||
CURRENT_EXIT_CODE=$?
|
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
CURRENT_EXIT_CODE=$?
|
||||||
}
|
}
|
||||||
|
|
||||||
function command_exists() {
|
function command_exists() {
|
||||||
local service_path=$1
|
local service_path=$1
|
||||||
local command=$2
|
local command=$2
|
||||||
@ -63,7 +74,7 @@ function command_exists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Get all services on the server
|
# Get all services on the server
|
||||||
SERVICES_PATH="${SCRIPT_DIR}/../../"
|
SERVICES_PATH=$(realpath "${SCRIPT_DIR}/../../")
|
||||||
|
|
||||||
# Get all service names
|
# Get all service names
|
||||||
SERVICE_NAMES=$(ls "${SERVICES_PATH}")
|
SERVICE_NAMES=$(ls "${SERVICES_PATH}")
|
||||||
@ -71,7 +82,7 @@ SERVICE_NAMES=$(ls "${SERVICES_PATH}")
|
|||||||
# Iterate over all service names
|
# Iterate over all service names
|
||||||
for SERVICE_NAME in ${SERVICE_NAMES}; do
|
for SERVICE_NAME in ${SERVICE_NAMES}; do
|
||||||
|
|
||||||
SERVICE_PATH="${SERVICES_PATH}/${SERVICE_NAME}"
|
SERVICE_PATH=$(realpath "${SERVICES_PATH}/${SERVICE_NAME}")
|
||||||
|
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
# Get the service health
|
# Get the service health
|
||||||
|
Loading…
x
Reference in New Issue
Block a user