This commit is contained in:
John
2025-04-27 09:34:04 +12:00
parent 3c50260ed3
commit c6665f3044
11 changed files with 75 additions and 37 deletions

View File

@ -87,10 +87,8 @@ bool service_runner::install() {
// Run install script
{
std::string install_cmd = m_server_env.construct_standard_command_run_cmd(m_service_info.service_name, "install");
bool ok= m_server_env.execute_ssh_command(install_cmd, "Failed to run install script");
if (!ok)
return false;
std::vector<std::string> args; // not passed through yet.
m_server_env.run_remote_template_command(m_service_info.service_name, "install", args);
}
// print health tick
@ -114,10 +112,11 @@ bool service_runner::uninstall() {
bool script_exists = m_server_env.check_remote_file_exists(uninstall_script);
if (script_exists) {
std::string uninstall_cmd = m_server_env.construct_standard_command_run_cmd(m_service_info.service_name, "uninstall");
if (!m_server_env.execute_ssh_command(uninstall_cmd, "Failed to run uninstall script")) {
std::vector<std::string> args; // not passed through yet.
if (!m_server_env.run_remote_template_command(m_service_info.service_name, "uninstall", args)) {
std::cerr << "Warning: Uninstall script failed, but continuing with directory removal" << std::endl;
}
} else {
std::cerr << "Warning: No uninstall script found. Unable to uninstall service." << std::endl;
return false;
@ -188,8 +187,8 @@ bool service_runner::run_command(const std::string& command) {
}
// Run the generic command
std::string run_cmd = m_server_env.construct_standard_command_run_cmd(m_service_info.service_name, command);
return m_server_env.execute_ssh_command(run_cmd, "Command returned error code: " + script_path);
std::vector<std::string> args; // not passed through yet.
return m_server_env.run_remote_template_command(m_service_info.service_name, command, args);
}
@ -280,11 +279,9 @@ HealthStatus service_runner::is_healthy()
}
// Run status script, does not display output.
std::string run_cmd = m_server_env.construct_standard_command_run_cmd(m_service_info.service_name, "status");
bool ok = m_server_env.execute_ssh_command(run_cmd, "");
if (!ok)
std::vector<std::string> args; // not passed through yet.
if (!m_server_env.run_remote_template_command(m_service_info.service_name, "status", args))
return HealthStatus::UNHEALTHY;
return HealthStatus::HEALTHY;
}
@ -408,8 +405,8 @@ void service_runner::interactive_ssh_service()
return;
}
std::string command = m_server_env.construct_standard_command_run_cmd(m_service_info.service_name, "ssh");
interactive_ssh(m_server_name, "/bin/bash -c '"+command+"'");
std::vector<std::string> args; // not passed through yet.
m_server_env.run_remote_template_command(m_service_info.service_name, "ssh", args);
}
void service_runner::edit_service_config()