This commit is contained in:
John 2025-04-27 13:51:36 +12:00
parent c35fabe6e7
commit 13b1327da7
12 changed files with 11 additions and 63 deletions

View File

@ -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;
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) {
argstr += " " + quote(dequote(trim(arg)));
}

View File

@ -274,14 +274,7 @@ HealthStatus service_runner::is_healthy()
return HealthStatus::ERROR;
}
// Check if status script exists
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";
std::string script_path = get_remote_service_template_path(m_server_name, m_service_info.service_name) + "/status.sh";
if (!m_server_env.check_remote_file_exists(script_path)) {
std::cerr << "Service is not installed: " << m_service_info.service_name << std::endl;
return HealthStatus::NOTINSTALLED;
@ -319,7 +312,7 @@ std::string service_runner::HealthStatus2String(HealthStatus status)
else if (status == HealthStatus::UNHEALTHY)
return ":cross:";
else if (status == HealthStatus::UNKNOWN)
return ":question:";
return ":greytick:";
else if (status == HealthStatus::NOTINSTALLED)
return ":warning:";
else

View File

@ -36,7 +36,9 @@ const std::map<std::string, coloredText> kReplacements = {
{":check:", {"+", kTextColor_Green}},
{":x:", {"x", 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

View File

@ -1,23 +1,3 @@
DropShell Template Example
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
DropShell agent.
Required for health checks etc.

View File

@ -54,7 +54,3 @@ for SERVICE_NAME in ${SERVICE_NAMES}; do
echo "${SERVICE_NAME}_HEALTH=${SERVICE_HEALTH}"
echo "${SERVICE_NAME}_PORTS=${SERVICE_PORTS}"
done

View File

@ -0,0 +1 @@
#

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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}"
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}"

View File

@ -6,7 +6,7 @@
# It is called with the path to the server specific env file as an argument.
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."

View File

@ -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."
echo "Service is healthy"
exit 0