Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCHv2] Detect when instance is run or restarted by tarantoolctl.
@ 2018-07-02 14:48 Serge Petrenko
  2018-07-04 18:04 ` [tarantool-patches] " Konstantin Osipov
  0 siblings, 1 reply; 3+ messages in thread
From: Serge Petrenko @ 2018-07-02 14:48 UTC (permalink / raw)
  To: tarantool-patches; +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)

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

* [tarantool-patches] Re: [PATCHv2] Detect when instance is run or restarted by tarantoolctl.
  2018-07-02 14:48 [tarantool-patches] [PATCHv2] Detect when instance is run or restarted by tarantoolctl Serge Petrenko
@ 2018-07-04 18:04 ` Konstantin Osipov
  2018-07-05  6:58   ` Sergey Petrenko
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Osipov @ 2018-07-04 18:04 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Serge Petrenko

* Serge Petrenko <sergepetrenko@tarantool.org> [18/07/02 17:54]:
> 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

Hi,

Please add a petition to docbot to the commit message.

Re TARANTOOL_RESTARTED, let's discuss this - I don't think 
this is going to address 
https://github.com/tarantool/tarantool/issues/3384
and gh-3215 is not asking for it.

So for now I would remove it from the patch.

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

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

* [tarantool-patches] Re: [PATCHv2] Detect when instance is run or restarted by tarantoolctl.
  2018-07-04 18:04 ` [tarantool-patches] " Konstantin Osipov
@ 2018-07-05  6:58   ` Sergey Petrenko
  0 siblings, 0 replies; 3+ messages in thread
From: Sergey Petrenko @ 2018-07-05  6:58 UTC (permalink / raw)
  To: Konstantin Osipov, tarantool-patches


04.07.2018 21:04, Konstantin Osipov пишет:
> * Serge Petrenko <sergepetrenko@tarantool.org> [18/07/02 17:54]:
>> 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
> Hi,
>
> Please add a petition to docbot to the commit message.
Hi, thank you for review. Petition added:

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

@TarantoolBot document
Title: tarantoolctl: document setting environment variables
tarantoolctl sets the `TARANTOOLCTL` environment variable when starting
an instance, and sets the `TARANTOOL_RESTARTED' environment variable
when restarting.
---
  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
>
> Re TARANTOOL_RESTARTED, let's discuss this - I don't think
> this is going to address
> https://github.com/tarantool/tarantool/issues/3384
> and gh-3215 is not asking for it.
>
> So for now I would remove it from the patch.
>
I believe you asked for it in the comments, if I understood correctly:
https://github.com/tarantool/tarantool/issues/3215#issuecomment-388223021

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

end of thread, other threads:[~2018-07-05  6:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 14:48 [tarantool-patches] [PATCHv2] Detect when instance is run or restarted by tarantoolctl Serge Petrenko
2018-07-04 18:04 ` [tarantool-patches] " Konstantin Osipov
2018-07-05  6:58   ` Sergey Petrenko

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