Update source/src/commands/list.cpp
This commit is contained in:
@@ -232,11 +232,21 @@ void show_server_details(const std::string& server_name) {
|
|||||||
|
|
||||||
info << std::endl << "Server Status:" << std::endl;
|
info << std::endl << "Server Status:" << std::endl;
|
||||||
info << std::string(40, '-') << std::endl;
|
info << std::string(40, '-') << std::endl;
|
||||||
|
|
||||||
// Try to connect to the server (using our improved timeout)
|
// Try to connect to the server (using our improved timeout)
|
||||||
bool is_online = execute_ssh_command(sshinfo, sCommand("", "true", {}), cMode::Silent);
|
bool is_online = execute_ssh_command(sshinfo, sCommand("", "true", {}), cMode::Silent);
|
||||||
|
bool agent_match = false;
|
||||||
|
std::map<std::string, shared_commands::ServiceStatus> service_status_map;
|
||||||
|
|
||||||
if (is_online) {
|
if (is_online) {
|
||||||
info << "Status: Online" << std::endl;
|
info << "Status: Online" << std::endl;
|
||||||
|
// Get all service status and agent match in one call
|
||||||
|
service_status_map = shared_commands::get_all_services_status(env, &agent_match);
|
||||||
|
if (agent_match) {
|
||||||
|
info << "Agent: Up to date" << std::endl;
|
||||||
|
} else {
|
||||||
|
warning << "Agent: Out of date - run 'ds install " << server_name << "' to update" << std::endl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warning << "Status: Offline" << std::endl;
|
warning << "Status: Offline" << std::endl;
|
||||||
}
|
}
|
||||||
@@ -272,23 +282,19 @@ void show_server_details(const std::string& server_name) {
|
|||||||
tp.add_row({"Status", "Service", "Template","Ports"});
|
tp.add_row({"Status", "Service", "Template","Ports"});
|
||||||
|
|
||||||
if (is_online) {
|
if (is_online) {
|
||||||
std::map<std::string, shared_commands::ServiceStatus> status = shared_commands::get_all_services_status(server_name);
|
for (const auto& [service_name, service_status] : service_status_map) {
|
||||||
|
|
||||||
std::set<int> ports_used;
|
|
||||||
std::string serviceticks = "";
|
|
||||||
for (const auto& [service_name, service_status] : status) {
|
|
||||||
std::string healthy = shared_commands::HealthStatus2String(service_status.health);
|
std::string healthy = shared_commands::HealthStatus2String(service_status.health);
|
||||||
|
|
||||||
std::string ports_str = "";
|
std::string ports_str = "";
|
||||||
for (const auto& port : service_status.ports)
|
for (const auto& port : service_status.ports)
|
||||||
ports_str += std::to_string(port) + " ";
|
ports_str += std::to_string(port) + " ";
|
||||||
|
|
||||||
std::string template_name = get_service_info(server_name,service_name).template_name;
|
std::string template_name = get_service_info(server_name,service_name).template_name;
|
||||||
if (template_name.empty())
|
if (template_name.empty())
|
||||||
template_name = "Unknown";
|
template_name = "Unknown";
|
||||||
|
|
||||||
tp.add_row({healthy, service_name, template_name, ports_str});
|
tp.add_row({healthy, service_name, template_name, ports_str});
|
||||||
} // end of for (const auto& service : services)
|
}
|
||||||
} else {
|
} else {
|
||||||
// Server is offline, just list services without checking their status
|
// Server is offline, just list services without checking their status
|
||||||
std::vector<LocalServiceInfo> services = get_server_services_info(server_name);
|
std::vector<LocalServiceInfo> services = get_server_services_info(server_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user