.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "init_user_directory.hpp"
|
||||
#include "dropshell.hpp"
|
||||
#include "server_env.hpp"
|
||||
#include "server_service.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@ -94,34 +95,19 @@ void show_server_details(const std::string& server_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
fs::path env_file = server_dir / "_server.env";
|
||||
if (!fs::exists(env_file)) {
|
||||
std::cerr << "Error: Server configuration file not found" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "Server Details: " << server_name << std::endl;
|
||||
//---------------------
|
||||
std::cout << "Server Configuration: " << server_name << std::endl;
|
||||
std::cout << std::string(40, '-') << std::endl;
|
||||
|
||||
std::ifstream file(env_file.string());
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
if (!line.empty() && line[0] != '#') {
|
||||
std::cout << line << 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
|
||||
std::string ssh_address;
|
||||
file.clear();
|
||||
file.seekg(0);
|
||||
while (std::getline(file, line)) {
|
||||
if (boost::starts_with(line, "SSH_ADDRESS=")) {
|
||||
ssh_address = line.substr(12);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string ssh_address = env.get_SSH_HOST();
|
||||
if (!ssh_address.empty()) {
|
||||
std::cout << std::endl << "Server Status:" << std::endl;
|
||||
std::cout << std::string(40, '-') << std::endl;
|
||||
@ -142,6 +128,26 @@ void show_server_details(const std::string& server_name) {
|
||||
std::cout << "Status: Offline" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// list services, and run healthcheck on each
|
||||
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;
|
||||
server_service ss;
|
||||
if (ss.init(server_name, service))
|
||||
if (ss.is_healthy())
|
||||
healthy=true;
|
||||
|
||||
std::cout << service << ": " << (healthy ? green_tick : red_cross) << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
Reference in New Issue
Block a user