[Tarantool-patches] [PATCH 2/2] feedback_daemon: send feedback on tarantool exit

Serge Petrenko sergepetrenko at tarantool.org
Thu Dec 24 16:34:51 MSK 2020


Feedback daemon is now able to send feedback once tarantool exits.
This helps to gather statistics for instances that shut down even before
the first feedback_interval passes.
---
 src/box/lua/feedback_daemon.lua | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/box/lua/feedback_daemon.lua b/src/box/lua/feedback_daemon.lua
index 1aac32bb3..f42ab5822 100644
--- a/src/box/lua/feedback_daemon.lua
+++ b/src/box/lua/feedback_daemon.lua
@@ -355,6 +355,13 @@ local function guard_loop(self)
     self.shutdown:put("stopped")
 end
 
+-- An on_shutdown trigger to fire on tarantool exit.
+local function on_shutdown(self)
+    if self.control ~= nil then
+        self.control:put("send")
+    end
+end
+
 -- these functions are used for test purposes only
 local function start(self)
     self:stop()
@@ -400,6 +407,9 @@ setmetatable(daemon, {
         generate_feedback = function()
             return fill_in_feedback({ feedback_version = 5 })
         end,
+        on_shutdown = function()
+            on_shutdown(daemon)
+        end,
         start = function()
             start(daemon)
         end,
@@ -437,3 +447,6 @@ if box.internal == nil then
 else
     box.internal[PREFIX] = daemon
 end
+
+-- Send feedback on Tarantool exit.
+box.ctl.on_shutdown(function() daemon:on_shutdown() end)
-- 
2.24.3 (Apple Git-128)



More information about the Tarantool-patches mailing list