From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 84C2D2567F for ; Mon, 19 Aug 2019 03:40:00 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OF04BKoxfXBV for ; Mon, 19 Aug 2019 03:40:00 -0400 (EDT) Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 015D52566E for ; Mon, 19 Aug 2019 03:39:59 -0400 (EDT) From: "Max Melentiev" (Redacted sender "m.melentiev" for DMARC) Subject: [tarantool-patches] [PATCH] tarantoolctl doesn't fail when box.cfg is delayed in init script Date: Mon, 19 Aug 2019 10:39:36 +0300 Message-Id: <20190819073936.37388-1-m.melentiev@corp.mail.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org 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