Update source/src/commands/list.cpp
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 28s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m15s

This commit is contained in:
j
2026-01-02 22:38:16 +13:00
parent 226707539b
commit 2beea9e16e

View File

@@ -235,8 +235,18 @@ void show_server_details(const std::string& server_name) {
// Try to connect to the server (using our improved timeout)
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) {
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 {
warning << "Status: Offline" << std::endl;
}
@@ -272,11 +282,7 @@ void show_server_details(const std::string& server_name) {
tp.add_row({"Status", "Service", "Template","Ports"});
if (is_online) {
std::map<std::string, shared_commands::ServiceStatus> status = shared_commands::get_all_services_status(server_name);
std::set<int> ports_used;
std::string serviceticks = "";
for (const auto& [service_name, service_status] : status) {
for (const auto& [service_name, service_status] : service_status_map) {
std::string healthy = shared_commands::HealthStatus2String(service_status.health);
std::string ports_str = "";
@@ -288,7 +294,7 @@ void show_server_details(const std::string& server_name) {
template_name = "Unknown";
tp.add_row({healthy, service_name, template_name, ports_str});
} // end of for (const auto& service : services)
}
} else {
// Server is offline, just list services without checking their status
std::vector<LocalServiceInfo> services = get_server_services_info(server_name);