This commit is contained in:
Your Name
2025-04-21 22:49:10 +12:00
parent 013176dbe5
commit c5ed85c8e9
3 changed files with 56 additions and 53 deletions

View File

@ -65,7 +65,7 @@ void list_servers() {
if (ss.init(server.name, service))
{
if (ss.is_healthy())
serviceticks += ":tick: :tick: :cross: ";
serviceticks += ":tick: ";
else
serviceticks += ":cross: ";
}
@ -100,15 +100,8 @@ void show_server_details(const std::string& server_name) {
return;
}
//---------------------
std::cout << "Server Configuration: " << server_name << std::endl;
std::cout << std::string(40, '-') << std::endl;
server_env env(server_dir.string());
for (const auto& [key, value] : env.get_variables()) {
std::cout << key << ": " << value << std::endl;
}
//---------------------
// Check if server is reachable via SSH
@ -134,39 +127,46 @@ void show_server_details(const std::string& server_name) {
}
}
//---------------------
{
tableprint tp("Server Configuration: " + server_name, true);
tp.add_row({"Key", "Value"});
for (const auto& [key, value] : env.get_variables()) {
tp.add_row({key, value});
}
tp.print();
}
//---------------------
// list services, and run healthcheck on each
std::cout << std::endl;
std::cout << "Services: " << server_name << std::endl;
std::cout << std::string(40, '-') << std::endl;
std::string green_tick = "\033[32m✓\033[0m";
std::string red_cross = "\033[31m✗\033[0m";
std::vector<std::string> services = get_server_services(server_name);
for (const auto& service : services) {
bool healthy = false;
std::vector<int> ports;
server_service ss;
if (ss.init(server_name, service))
{
if (ss.is_healthy())
healthy=true;
ports = ss.get_ports();
}
std::cout << " " << (healthy ? green_tick : red_cross) << " " << service << ", ports: ";
std::cout << "(";
bool first = true;
for (const auto& port : ports) {
if (!first) {
std::cout << ", ";
{
tableprint tp("Services: " + server_name, false);
tp.add_row({"Status", "Service", "Ports"});
std::vector<std::string> services = get_server_services(server_name);
for (const auto& service : services) {
bool healthy = false;
std::vector<int> ports;
server_service ss;
if (ss.init(server_name, service))
{
if (ss.is_healthy())
healthy=true;
ports = ss.get_ports();
}
std::cout << port;
first = false;
}
std::cout << ")" << std::endl;
}
}
bool first = true;
std::string ports_str = "";
for (const auto& port : ports) {
if (!first) {
ports_str += ", ";
}
ports_str += std::to_string(port);
first = false;
}
tp.add_row({healthy ? ":tick:" : ":cross:", service, ports_str});
} // end of for (const auto& service : services)
tp.print();
} // end of list services
} // end of show_server_details
} // namespace dropshell