tidying
This commit is contained in:
parent
c35fabe6e7
commit
13b1327da7
@ -79,7 +79,7 @@ std::string server_env::construct_standard_command_run_cmd(const std::string &se
|
|||||||
std::map<std::string, std::string> env_vars;
|
std::map<std::string, std::string> env_vars;
|
||||||
get_all_service_env_vars(service_name, env_vars);
|
get_all_service_env_vars(service_name, env_vars);
|
||||||
|
|
||||||
std::string argstr = quote(remote_service_config_path);
|
std::string argstr = "";
|
||||||
for (const auto& arg : args) {
|
for (const auto& arg : args) {
|
||||||
argstr += " " + quote(dequote(trim(arg)));
|
argstr += " " + quote(dequote(trim(arg)));
|
||||||
}
|
}
|
||||||
|
@ -274,14 +274,7 @@ HealthStatus service_runner::is_healthy()
|
|||||||
return HealthStatus::ERROR;
|
return HealthStatus::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if status script exists
|
std::string script_path = get_remote_service_template_path(m_server_name, m_service_info.service_name) + "/status.sh";
|
||||||
std::string command = "status";
|
|
||||||
|
|
||||||
if (!template_command_exists(m_service_info.template_name, command)) {
|
|
||||||
return HealthStatus::UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string script_path = mRemote_service_template_path + "/" + command + ".sh";
|
|
||||||
if (!m_server_env.check_remote_file_exists(script_path)) {
|
if (!m_server_env.check_remote_file_exists(script_path)) {
|
||||||
std::cerr << "Service is not installed: " << m_service_info.service_name << std::endl;
|
std::cerr << "Service is not installed: " << m_service_info.service_name << std::endl;
|
||||||
return HealthStatus::NOTINSTALLED;
|
return HealthStatus::NOTINSTALLED;
|
||||||
@ -319,7 +312,7 @@ std::string service_runner::HealthStatus2String(HealthStatus status)
|
|||||||
else if (status == HealthStatus::UNHEALTHY)
|
else if (status == HealthStatus::UNHEALTHY)
|
||||||
return ":cross:";
|
return ":cross:";
|
||||||
else if (status == HealthStatus::UNKNOWN)
|
else if (status == HealthStatus::UNKNOWN)
|
||||||
return ":question:";
|
return ":greytick:";
|
||||||
else if (status == HealthStatus::NOTINSTALLED)
|
else if (status == HealthStatus::NOTINSTALLED)
|
||||||
return ":warning:";
|
return ":warning:";
|
||||||
else
|
else
|
||||||
|
@ -36,7 +36,9 @@ const std::map<std::string, coloredText> kReplacements = {
|
|||||||
{":check:", {"+", kTextColor_Green}},
|
{":check:", {"+", kTextColor_Green}},
|
||||||
{":x:", {"x", kTextColor_Red}},
|
{":x:", {"x", kTextColor_Red}},
|
||||||
{":error:", {"!", kTextColor_Red}},
|
{":error:", {"!", kTextColor_Red}},
|
||||||
{":question:", {"?", kTextColor_DarkGrey}}
|
{":question:", {"?", kTextColor_DarkGrey}},
|
||||||
|
{":greytick:", {"+", kTextColor_LightGrey}},
|
||||||
|
{":greycross:", {"x", kTextColor_LightGrey}}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function to get ANSI color code
|
// Helper function to get ANSI color code
|
||||||
|
@ -1,23 +1,3 @@
|
|||||||
DropShell Template Example
|
DropShell agent.
|
||||||
|
|
||||||
Shell scripts defined in this folder are run as DropShell commands on the remote server (not locally!).
|
|
||||||
All scripts are passed the directory containing the server-specific service environment (SSSE) as an argument
|
|
||||||
(the environment file, along with any other server and service-specific files, is then in $1/service.env)
|
|
||||||
|
|
||||||
The default SSSE file included when a new service is created is in example/service.env. This must exist,
|
|
||||||
and must at minimum contain the TEMPLATE=<template_name> variable.
|
|
||||||
|
|
||||||
The optional backups script gets a second argument, which is the backup file to create (a single tgz file).
|
|
||||||
|
|
||||||
Mandatory scripts are:
|
|
||||||
- install.sh
|
|
||||||
- uninstall.sh
|
|
||||||
- start.sh
|
|
||||||
- stop.sh
|
|
||||||
|
|
||||||
Optional standard scripts are:
|
|
||||||
- backup.sh
|
|
||||||
- status.sh
|
|
||||||
- ports.sh
|
|
||||||
- logs.sh
|
|
||||||
|
|
||||||
|
Required for health checks etc.
|
||||||
|
@ -54,7 +54,3 @@ for SERVICE_NAME in ${SERVICE_NAMES}; do
|
|||||||
echo "${SERVICE_NAME}_HEALTH=${SERVICE_HEALTH}"
|
echo "${SERVICE_NAME}_HEALTH=${SERVICE_HEALTH}"
|
||||||
echo "${SERVICE_NAME}_PORTS=${SERVICE_PORTS}"
|
echo "${SERVICE_NAME}_PORTS=${SERVICE_PORTS}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1
templates/dropshell-agent/_default.env
Normal file
1
templates/dropshell-agent/_default.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
#
|
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# START SCRIPT
|
|
||||||
# The start script is required for all templates.
|
|
||||||
# It is used to start the service on the server.
|
|
||||||
# It is called with the path to the server specific env file as an argument.
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# STATUS SCRIPT
|
|
||||||
# The status script is OPTIONAL.
|
|
||||||
# It is used to return the status of the service (0 is healthy, 1 is unhealthy).
|
|
||||||
# It is called with the path to the server specific env file as an argument.
|
|
||||||
|
|
||||||
exit 0
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# STOP SCRIPT
|
|
||||||
# The stop script is required for all templates.
|
|
||||||
# It is used to stop the service on the server.
|
|
||||||
# It is called with the path to the server specific env file as an argument.
|
|
||||||
|
|
@ -38,4 +38,4 @@ _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER
|
|||||||
bash ./start.sh $1 || die "Failed to start container ${CONTAINER_NAME}"
|
bash ./start.sh $1 || die "Failed to start container ${CONTAINER_NAME}"
|
||||||
|
|
||||||
echo "Installation of ${CONTAINER_NAME} complete"
|
echo "Installation of ${CONTAINER_NAME} complete"
|
||||||
echo "You can access the service at http://${SERVER}:{HOST_PORT}"
|
echo "You can access the service at http://${SERVER}:${HOST_PORT}"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# It is called with the path to the server specific env file as an argument.
|
# It is called with the path to the server specific env file as an argument.
|
||||||
|
|
||||||
source "$(dirname "$0")/_common.sh"
|
source "$(dirname "$0")/_common.sh"
|
||||||
check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "CONTAINER_PORT" "LOCAL_DATA_FOLDER"
|
check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "LOCAL_DATA_FOLDER"
|
||||||
|
|
||||||
[ -d "${LOCAL_DATA_FOLDER}" ] || die "Local data folder ${LOCAL_DATA_FOLDER} does not exist."
|
[ -d "${LOCAL_DATA_FOLDER}" ] || die "Local data folder ${LOCAL_DATA_FOLDER} does not exist."
|
||||||
|
|
||||||
|
@ -12,4 +12,3 @@ _is_container_running $CONTAINER_NAME || die "Service is not running - did not f
|
|||||||
# || die "Service is not healthy - did not get OK response from /health endpoint."
|
# || die "Service is not healthy - did not get OK response from /health endpoint."
|
||||||
|
|
||||||
echo "Service is healthy"
|
echo "Service is healthy"
|
||||||
exit 0
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user