Skip to content

Commit 2d78a64

Browse files
authored
Merge pull request #14 from orchaton/v5
shutdown runat and worker when node is in ro state
2 parents 75ea408 + 1a15304 commit 2d78a64

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

xqueue.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@ function M.upgrade(space,opts,depth)
686686
end
687687
end
688688

689+
self.ready = fiber.channel(0)
690+
689691
if opts.worker then
690692
local workers = opts.workers or 1
691693
local worker = opts.worker
@@ -697,6 +699,10 @@ function M.upgrade(space,opts,depth)
697699
repeat fiber.sleep(0.001) until space.xq
698700
if xq.ready then xq.ready:get() end
699701
log.info("I am worker %s",i)
702+
if box.info.ro then
703+
log.notice("Shutting down on ro instance")
704+
return
705+
end
700706
while box.space[space.name] and space.xq == xq do
701707
local task = space:take(1)
702708
if task then
@@ -731,6 +737,10 @@ function M.upgrade(space,opts,depth)
731737
if xq.ready then xq.ready:get() end
732738
local chan = xq.runat_chan
733739
log.info("Runat started")
740+
if box.info.ro then
741+
log.notice("Shutting down on ro instance")
742+
return
743+
end
734744
local maxrun = 1000
735745
local curwait
736746
local collect = {}
@@ -881,7 +891,6 @@ function M.upgrade(space,opts,depth)
881891
end
882892
self.ready = nil
883893
end
884-
self.ready = fiber.channel(0)
885894

886895
local meta = debug.getmetatable(space)
887896
for k,v in pairs(methods) do meta[k] = v end

0 commit comments

Comments
 (0)