Broken while we implement version control.
This commit is contained in:
parent
66bc230f71
commit
a9b05d2ffa
@ -318,6 +318,34 @@ std::string service_runner::HealthStatus2String(HealthStatus status)
|
||||
return ":error:";
|
||||
}
|
||||
|
||||
bool service_runner::ensure_service_dropshell_files_up_to_date()
|
||||
{
|
||||
if (!m_server_env.is_valid()) {
|
||||
std::cerr << "Error: Server service not initialized" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if the service template and config are up to date on the remote server.
|
||||
service_versions versions(m_server_name, m_service_info.service_name);
|
||||
if (versions.remote_up_to_date())
|
||||
return true;
|
||||
|
||||
if (!versions.remote_template_is_up_to_date()) {
|
||||
std::cerr << "Error: Service template is not up to date on the remote server" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!versions.remote_config_is_up_to_date()) {
|
||||
std::cerr << "Error: Service config is not up to date on the remote server" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO - actually update things!
|
||||
|
||||
versions.update_stored_remote_versions();
|
||||
return versions.remote_up_to_date();
|
||||
}
|
||||
|
||||
std::string service_runner::healthmark()
|
||||
{
|
||||
HealthStatus status = is_healthy();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "services.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
#include "utils/assert.hpp"
|
||||
#include "utils/hash.hpp"
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
@ -58,6 +59,9 @@ class service_runner {
|
||||
static std::map<std::string, ServiceStatus> get_all_services_status(std::string server_name);
|
||||
static std::string HealthStatus2String(HealthStatus status);
|
||||
|
||||
// ensure the service related dropshell files (template and config) are up to date on the remote server.
|
||||
bool ensure_service_dropshell_files_up_to_date();
|
||||
|
||||
private:
|
||||
// install the service over ssh, using the credentials from server.env (via server_env.hpp), by:
|
||||
// 1. check if the server_name exists, and the service_name refers to a valid template
|
||||
@ -108,6 +112,33 @@ void interactive_ssh(const std::string & server_name, const std::string & comman
|
||||
void edit_server(const std::string & server_name);
|
||||
void edit_file(const std::string & file_path, const std::string & aftertext);
|
||||
|
||||
// check if the service template and config are up to date on the remote server.
|
||||
class service_versions {
|
||||
public:
|
||||
service_versions(const std::string & server_name, const std::string & service_name);
|
||||
|
||||
bool remote_up_to_date() { return remote_template_is_up_to_date() && remote_config_is_up_to_date(); }
|
||||
|
||||
bool remote_template_is_up_to_date() { return get_version_remote_service_template() == calculate_version_local_service_template(); }
|
||||
bool remote_config_is_up_to_date() { return get_version_remote_config() == calculate_version_local_config(); }
|
||||
|
||||
XXH64_hash_t calculate_version_local_service_template();
|
||||
XXH64_hash_t calculate_version_local_config();
|
||||
|
||||
void update_stored_remote_versions();
|
||||
XXH64_hash_t get_version_remote_config();
|
||||
XXH64_hash_t get_version_remote_service_template();
|
||||
|
||||
private:
|
||||
XXH64_hash_t calculate_version_remote_service_template();
|
||||
XXH64_hash_t calculate_version_remote_config();
|
||||
|
||||
private:
|
||||
std::string m_server_name;
|
||||
std::string m_service_name;
|
||||
};
|
||||
|
||||
|
||||
} // namespace dropshell
|
||||
|
||||
#endif // SERVICE_RUNNER_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user