From 61e000647bc1f1682f746ed36da1f9a43805d368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=9D=D0=B0=D0=B9=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2?= Date: Wed, 7 May 2025 16:27:19 +0300 Subject: [PATCH] Add on_before_reload callback package.reload call it before reload it stop reload if fail --- config.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config.lua b/config.lua index edc2dca..e68721c 100644 --- a/config.lua +++ b/config.lua @@ -812,6 +812,18 @@ local M enforce_ro = M._enforced_ro, } end, + on_before_reload = function() + -- stop reload if + -- * etcd is unavailable + -- * etcd has no configuration + if M.etcd then + log.info('Try to discovery etcd before reload') + M.etcd:discovery() + + log.info('Try to get etcd config before reload') + assert(M.etcd:get_all(), 'etcd has no configuration') + end + end, _load_cfg = load_cfg, },{ ---Reinitiates moonlibs.config