Tidy
This commit is contained in:
@ -100,9 +100,8 @@ bool service_runner::install() {
|
||||
}
|
||||
|
||||
// Check if template exists
|
||||
template_manager tm;
|
||||
template_info tinfo;
|
||||
if (!tm.get_template_info(m_service_info.template_name, tinfo)) {
|
||||
if (!get_template_info(m_service_info.template_name, tinfo)) {
|
||||
std::cerr << "Error: Template '" << m_service_info.template_name << "' not found" << std::endl;
|
||||
return false;
|
||||
}
|
||||
@ -164,6 +163,11 @@ bool service_runner::run_command(const std::string& command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!template_command_exists(m_service_info.template_name, command)) {
|
||||
std::cout << "No command script for " << m_service_info.template_name << " : " << command << std::endl;
|
||||
return true; // nothing to run.
|
||||
}
|
||||
|
||||
std::string script_path = mRemote_service_template_path + "/" + command + ".sh";
|
||||
|
||||
// Check if service directory exists
|
||||
@ -195,7 +199,13 @@ bool service_runner::backup() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string script_path = mRemote_service_template_path + "/_backup.sh";
|
||||
std::string command = "_backup";
|
||||
|
||||
std::string script_path = mRemote_service_template_path + "/" + command + ".sh";
|
||||
if (!template_command_exists(m_service_info.template_name, command)) {
|
||||
std::cout << "No backup script for " << m_service_info.template_name << std::endl;
|
||||
return true; // nothing to back up.
|
||||
}
|
||||
|
||||
// Check if basic installed stuff is in place.
|
||||
if (!check_remote_dir_exists(mRemote_service_path) || !check_remote_file_exists(script_path) || !check_remote_file_exists(mRemote_service_env_file))
|
||||
@ -252,7 +262,13 @@ service_runner::HealthStatus service_runner::is_healthy()
|
||||
}
|
||||
|
||||
// Check if status script exists
|
||||
std::string script_path = mRemote_service_template_path + "/_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 (!check_remote_file_exists(script_path)) {
|
||||
return HealthStatus::NOTINSTALLED;
|
||||
}
|
||||
@ -270,16 +286,34 @@ std::string service_runner::healthtick()
|
||||
std::string green_tick = "\033[32m✓\033[0m";
|
||||
std::string red_cross = "\033[31m✗\033[0m";
|
||||
std::string yellow_exclamation = "\033[33m!\033[0m";
|
||||
|
||||
std::string unknown = "\033[33m?\033[0m";
|
||||
|
||||
HealthStatus status = is_healthy();
|
||||
if (status == HealthStatus::HEALTHY)
|
||||
return green_tick;
|
||||
else if (status == HealthStatus::UNHEALTHY)
|
||||
return red_cross;
|
||||
else if (status == HealthStatus::UNKNOWN)
|
||||
return unknown;
|
||||
else
|
||||
return yellow_exclamation;
|
||||
}
|
||||
|
||||
std::string service_runner::healthmark()
|
||||
{
|
||||
HealthStatus status = is_healthy();
|
||||
if (status == HealthStatus::HEALTHY)
|
||||
return ":tick:";
|
||||
else if (status == HealthStatus::UNHEALTHY)
|
||||
return ":cross:";
|
||||
else if (status == HealthStatus::UNKNOWN)
|
||||
return ":question:";
|
||||
else if (status == HealthStatus::NOTINSTALLED)
|
||||
return ":warning:";
|
||||
else
|
||||
return ":error:";
|
||||
}
|
||||
|
||||
std::vector<int> service_runner::get_ports()
|
||||
{
|
||||
std::vector<int> ports;
|
||||
|
Reference in New Issue
Block a user