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 ECB5F25B8B for ; Mon, 19 Aug 2019 05:48:25 -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 tF-53YEFZdis for ; Mon, 19 Aug 2019 05:48:25 -0400 (EDT) Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 56C8225B78 for ; Mon, 19 Aug 2019 05:48:25 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: [tarantool-patches] Re: [PATCH] tarantoolctl doesn't fail when box.cfg is delayed in init script From: "Maxim Melentiev" (Redacted sender "m.melentiev" for DMARC) In-Reply-To: <20190819075457.GA18442@atlas> Date: Mon, 19 Aug 2019 12:48:22 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <59464C78-29E6-4F91-B8E9-CA01CB63FE65@corp.mail.ru> References: <20190819073936.37388-1-m.melentiev@corp.mail.ru> <20190819075457.GA18442@atlas> 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: Konstantin Osipov Cc: tarantool-patches@freelists.org =46rom cd94e49e7b23a30ed05e574eb8441b477fc1c47a Mon Sep 17 00:00:00 2001 From: Max Melentiev Date: Mon, 19 Aug 2019 10:35:55 +0300 Subject: [PATCH] tarantoolctl: allow to start instances without a = box.cfg{} Before this patch, tarantoolctl would fail if box.cfg{} was not called in an instance script. It used too patch box.cfg once again after init script to prevent chainging pid file. This patch allows to start an instance without immediate call to box.cfg{} in it. For example, managed instances which receive configuration from external server. @TarantoolBot document Title: tarantoolctl allows to start instances without a box.cfg{} tarantoolctl now works for instances without box.cfg{} or with dealyed box.cfg{} call. This can be managed instances which receive configuration from external server. For such instances `tarantoolctl start` goes to background when box.cfg{} is called, so it will wait until options for box.cfg are = received. However this is not the case for daemon management systems like systemd, as they handle bockgrounding on their side. --- 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 =3D getmetatable(box.cfg) + local orig_cfg_call =3D box_cfg_mt.__call + box_cfg_mt.__call =3D function(old_cfg, new_cfg) + if old_cfg.pid_file ~=3D nil and new_cfg ~=3D nil and = new_cfg.pid_file ~=3D nil then + new_cfg.pid_file =3D 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 =3D getmetatable(box.cfg) - if box_cfg_mt =3D=3D nil then - log.error('box.cfg() is not called in an instance file') - os.exit(1) - end - local old_call =3D box_cfg_mt.__call - box_cfg_mt.__call =3D function(old_cfg, cfg) - if old_cfg.pid_file ~=3D nil and cfg ~=3D nil and cfg.pid_file = ~=3D nil then - cfg.pid_file =3D old_cfg.pid_file - end - old_call(old_cfg, cfg) - end return 0 end -- 2.21.0 > On 19 Aug 2019, at 10:54, Konstantin Osipov = wrote: >=20 > * Max Melentiev [19/08/19 10:40]: >> 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. >=20 > Please explain better what this patch does, not how you achieved > that. >=20 > And while you are at it, explain why we need a secondary patching > of box.cfg at all. What's the point of preserving the pid file? >=20 > tarantoolctl: allow to start instances without a box.cfg{} >=20 > Before this patch, tarantoolctl would fail if box.cfg{} was not > called in an instance script. >=20 > This patch allows to start an instance without box.cfg{} in it.=20 > Such an instance: > - may only be started under systemd?=20 > - what can it do?=20 > - ??? >=20 > Please add a docboc entry, since it 's a significant behaviour > change. How such an instance is used?=20 >=20 > Otherwise LTGM. >=20 >=20 >> --- >> extra/dist/tarantoolctl.in | 21 +++++++++------------ >> 1 file changed, 9 insertions(+), 12 deletions(-) >>=20 >> 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 >>=20 >> + local box_cfg_mt =3D getmetatable(box.cfg) >> + local orig_cfg_call =3D box_cfg_mt.__call >> + box_cfg_mt.__call =3D function(old_cfg, new_cfg) >> + if old_cfg.pid_file ~=3D nil and new_cfg ~=3D nil and = new_cfg.pid_file ~=3D nil then >> + new_cfg.pid_file =3D old_cfg.pid_file >> + end >> + orig_cfg_call(old_cfg, new_cfg) >> + end >> + >> return data >> end >>=20 >> @@ -547,18 +556,6 @@ local function start() >> end >> os.exit(1) >> end >> - local box_cfg_mt =3D getmetatable(box.cfg) >> - if box_cfg_mt =3D=3D nil then >> - log.error('box.cfg() is not called in an instance file') >> - os.exit(1) >> - end >> - local old_call =3D box_cfg_mt.__call >> - box_cfg_mt.__call =3D function(old_cfg, cfg) >> - if old_cfg.pid_file ~=3D nil and cfg ~=3D nil and = cfg.pid_file ~=3D nil then >> - cfg.pid_file =3D old_cfg.pid_file >> - end >> - old_call(old_cfg, cfg) >> - end >> return 0 >> end >=20 > --=20 > Konstantin Osipov, Moscow, Russia