32 const boost::property_tree::ptree &cfg,
44 auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(
58 delay_ =
config_.get_child(
"module_config").get<
int>(
"delay", 120);
60 pubkey_ =
config_.get_child(
"module_config").get<std::string>(
"pubkey");
73 INFO(
"Current cfg version = " << local <<
". Remote = " << remote);
76 ERROR(
"Failed to retrieve config version");
86 INFO(
"Local configuration version is either equal or greated than the "
88 <<
" Doing nothing.");
94 auto task = std::make_shared<Tasks::GetLocalConfigVersion>(
utils_->kernel());
97 assert(task->succeed());
99 local = task->config_version_;
105 auto task = std::make_shared<Tasks::GetRemoteConfigVersion>(
endpoint_,
pubkey_);
109 if (!task->succeed())
111 if (task->get_exception())
115 std::rethrow_exception(task->get_exception());
117 catch (
const std::exception &e)
119 ERROR(
"Fetching remote version failed: " << e.what());
125 remote = task->config_version_;
131 INFO(
"Starting the synchronization process...");
134 auto fetch_task = std::make_shared<Tasks::FetchRemoteConfig>(
endpoint_,
pubkey_);
136 auto sync_task = std::make_shared<Tasks::SyncConfig>(
utils_->kernel(),
137 fetch_task,
true,
true);
138 sync_task->set_on_success([]() {
INFO(
"Synchronization complete."); });
140 auto *sched = &
utils_->scheduler();
141 fetch_task->set_on_success(