All fixed!
This commit is contained in:
parent
8c21260e49
commit
898cc97bae
@ -123,24 +123,39 @@ bool server_env::check_remote_items_exist(const std::vector<std::string> &file_p
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool server_env::execute_ssh_command(const sCommand& command) const {
|
bool server_env::execute_ssh_command(const sCommand& command) const {
|
||||||
std::string full_cmd = construct_ssh_cmd() + command.construct_safecmd();
|
std::string full_cmd = construct_ssh_cmd() + quote(command.construct_safecmd());
|
||||||
return execute_local_command(full_cmd);
|
bool okay = execute_local_command(full_cmd);
|
||||||
|
if (!okay) {
|
||||||
|
std::cerr << "Error: Failed to execute command on remote server: " << full_cmd << std::endl;
|
||||||
|
}
|
||||||
|
return okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool server_env::execute_ssh_command_and_capture_output(const sCommand& command, std::string &output) const
|
bool server_env::execute_ssh_command_and_capture_output(const sCommand& command, std::string &output) const
|
||||||
{
|
{
|
||||||
std::string full_cmd = construct_ssh_cmd() + command.construct_safecmd();
|
std::string full_cmd = construct_ssh_cmd() + quote(command.construct_safecmd());
|
||||||
return execute_local_command_and_capture_output(full_cmd, output);
|
bool okay = execute_local_command_and_capture_output(full_cmd, output);
|
||||||
|
if (!okay) {
|
||||||
|
std::cerr << "Error: Failed to execute command on remote server: " << full_cmd << std::endl;
|
||||||
|
}
|
||||||
|
return okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool server_env::run_remote_template_command(const std::string &service_name, const std::string &command, std::vector<std::string> args, bool silent) const
|
bool server_env::run_remote_template_command(const std::string &service_name, const std::string &command, std::vector<std::string> args, bool silent) const
|
||||||
{
|
{
|
||||||
std::string full_cmd = construct_standard_command_run_cmd(service_name, command, args, silent);
|
std::string full_cmd = construct_standard_command_run_cmd(service_name, command, args, silent);
|
||||||
return execute_ssh_command(full_cmd);
|
bool okay = execute_ssh_command(full_cmd);
|
||||||
|
if (!okay) {
|
||||||
|
std::cerr << "Error: Failed to execute command on remote server: " << full_cmd << std::endl;
|
||||||
|
}
|
||||||
|
return okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool server_env::execute_local_command(const sCommand& command) {
|
bool server_env::execute_local_command(const sCommand& command) {
|
||||||
bool okay = (system(command.construct_safecmd().c_str()) == 0);
|
bool okay = (system(command.construct_safecmd().c_str()) == 0);
|
||||||
|
if (!okay) {
|
||||||
|
std::cerr << "Error: Failed to execute command on local machine: " << command.construct_safecmd() << std::endl;
|
||||||
|
}
|
||||||
return okay;
|
return okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ bool service_runner::install() {
|
|||||||
std::string mkdir_cmd = "mkdir -p " + quote(mRemote_service_path);
|
std::string mkdir_cmd = "mkdir -p " + quote(mRemote_service_path);
|
||||||
if (!m_server_env.execute_ssh_command(mkdir_cmd))
|
if (!m_server_env.execute_ssh_command(mkdir_cmd))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create service directory" << std::endl;
|
std::cerr << "Failed to create service directory " << mRemote_service_path << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,21 +221,16 @@ std::map<std::string, ServiceStatus> service_runner::get_all_services_status(std
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string remote_service_path = get_remote_service_path(server_name, service_name);
|
|
||||||
std::string remote_service_config_path = get_remote_service_config_path(server_name, service_name);
|
|
||||||
std::string remote_service_template_path = get_remote_service_template_path(server_name, service_name);
|
|
||||||
std::string remote_service_env_file = get_remote_service_env_file(server_name, service_name);
|
|
||||||
|
|
||||||
server_env env(server_name);
|
server_env env(server_name);
|
||||||
if (!env.is_valid()) {
|
if (!env.is_valid()) {
|
||||||
std::cerr << "Error: Invalid server environment" << std::endl;
|
std::cerr << "Error: Invalid server environment" << std::endl;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string script_path = remote_service_template_path + "/" + command + ".sh";
|
std::string remote_service_template_path = get_remote_service_template_path(server_name, service_name);
|
||||||
|
sCommand scommand(remote_service_template_path, "/bin/bash " + quote(remote_service_template_path + "/" + command + ".sh"), {});
|
||||||
std::string output;
|
std::string output;
|
||||||
if (!env.execute_ssh_command_and_capture_output("'cd " + quote(remote_service_template_path) +
|
if (!env.execute_ssh_command_and_capture_output(scommand, output))
|
||||||
" && /bin/bash "+quote(script_path)+"'", output))
|
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
std::stringstream ss(output);
|
std::stringstream ss(output);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user