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 839E724344 for ; Mon, 2 Jul 2018 10:49: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 Q2LWHkcRu6oU for ; Mon, 2 Jul 2018 10:49:25 -0400 (EDT) Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (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 40ACE20C75 for ; Mon, 2 Jul 2018 10:49:25 -0400 (EDT) From: Serge Petrenko Subject: [tarantool-patches] [PATCHv2] Detect when instance is run or restarted by tarantoolctl. Date: Mon, 2 Jul 2018 17:48:22 +0300 Message-Id: <20180702144822.4860-1-sergepetrenko@tarantool.org> 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: Serge Petrenko There are some hacks to know the instance was run by tarantoolctl, none of them are too reliable, though. This patch introduces 2 environment variables set by tarantoolctl for the instance to know when it's being run or restarted. Closes: #3215 --- https://github.com/tarantool/tarantool/tree/sergepetrenko/gh-3215-tarantoolctl-detection https://github.com/tarantool/tarantool/issues/3215 Changes in v2: - scrape all and leave only the environment variables setting in tarantoolctl extra/dist/tarantoolctl.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in index b6b8e09c9..ecab0a0f1 100755 --- a/extra/dist/tarantoolctl.in +++ b/extra/dist/tarantoolctl.in @@ -514,6 +514,11 @@ local function start() script_name = instance_path, __defer_update = true } + + -- an env variable to tell when we the + -- instance is run under tarantoolctl + os.setenv('TARANTOOLCTL', 'true') + shift_argv(arg, 0, 2) local success, data = pcall(dofile, instance_path) -- if load fails - show last 10 lines of the log file and exit @@ -593,6 +598,9 @@ local function restart() end stop() fiber.sleep(1) + -- an env variable to tell when + -- the instance was restarted + os.setenv('TARANTOOL_RESTARTED', 'true') start() return 0 end -- 2.15.2 (Apple Git-101.1)