Broken while we implement version control.

This commit is contained in:
John
2025-04-27 22:01:30 +12:00
parent 66bc230f71
commit a9b05d2ffa
2 changed files with 59 additions and 0 deletions

View File

@ -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