Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] tarantoolctl doesn't fail when box.cfg is delayed in init script
@ 2019-08-19  7:39 Max Melentiev
  2019-08-19  7:54 ` [tarantool-patches] " Konstantin Osipov
  0 siblings, 1 reply; 10+ messages in thread
From: Max Melentiev @ 2019-08-19  7:39 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Max Melentiev

Before this patch tarantoolctl failed with error if box.cfg
was not called in init script because it used too patch box.cfg
once again after init script. I've changed it to patch box.cfg
second time inside wrapper_cfg.
---
 extra/dist/tarantoolctl.in | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 8adb57533..fd1abf9dc 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -483,6 +483,15 @@ local function wrapper_cfg(cfg)
         os.exit(1)
     end
 
+    local box_cfg_mt = getmetatable(box.cfg)
+    local orig_cfg_call = box_cfg_mt.__call
+    box_cfg_mt.__call = function(old_cfg, new_cfg)
+        if old_cfg.pid_file ~= nil and new_cfg ~= nil and new_cfg.pid_file ~= nil then
+            new_cfg.pid_file = old_cfg.pid_file
+        end
+        orig_cfg_call(old_cfg, new_cfg)
+    end
+
     return data
 end
 
@@ -547,18 +556,6 @@ local function start()
         end
         os.exit(1)
     end
-    local box_cfg_mt = getmetatable(box.cfg)
-    if box_cfg_mt == nil then
-        log.error('box.cfg() is not called in an instance file')
-        os.exit(1)
-    end
-    local old_call = box_cfg_mt.__call
-    box_cfg_mt.__call = function(old_cfg, cfg)
-        if old_cfg.pid_file ~= nil and cfg ~= nil and cfg.pid_file ~= nil then
-            cfg.pid_file = old_cfg.pid_file
-        end
-        old_call(old_cfg, cfg)
-    end
     return 0
 end
 
-- 
2.21.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-08-22 13:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19  7:39 [tarantool-patches] [PATCH] tarantoolctl doesn't fail when box.cfg is delayed in init script Max Melentiev
2019-08-19  7:54 ` [tarantool-patches] " Konstantin Osipov
2019-08-19  9:48   ` Maxim Melentiev
2019-08-19 15:05     ` Alexander Turenko
2019-08-20 11:24       ` Maxim Melentiev
2019-08-20 11:55         ` Konstantin Osipov
2019-08-20 23:15         ` Alexander Turenko
2019-08-22 13:06           ` Kirill Yukhin
2019-08-20 11:54     ` Konstantin Osipov
2019-08-20 12:08   ` Maxim Melentiev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox