File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,9 +92,14 @@ function graphite.init(opts)
9292 local sock = socket (' AF_INET' , ' SOCK_DGRAM' , ' udp' )
9393 assert (sock ~= nil , ' Socket creation failed' )
9494
95+ -- require('config'):reload() triggers calling only validate() and apply()
96+ -- role's methods without stop().
97+ -- so, we should kill previous fiber if exist.
9598 for name in pairs (GRAPHITE_FIBERS ) do
9699 if name == graphite_fiber .name then
97- error (' failed to start fiber: ' .. graphite_fiber .name .. " , already exist" )
100+ fiber .kill (GRAPHITE_FIBERS [name ].fiber )
101+ GRAPHITE_FIBERS [name ] = nil
102+ require (' fiber' ).yield ()
98103 end
99104 end
100105
Original file line number Diff line number Diff line change @@ -221,3 +221,30 @@ g.test_graphite_stop_custom_fiber = function(cg)
221221 t .assert_equals (count_workers (), 0 )
222222 end )
223223end
224+
225+ g .test_graphite_double_start = function (cg )
226+ cg .server :exec (function ()
227+ local fiber = require (' fiber' )
228+ local fun = require (' fun' )
229+ local graphite = require (' metrics.plugins.graphite' )
230+
231+ local function count_workers ()
232+ return fun .iter (fiber .info ()):
233+ filter (function (_ , x ) return string.find (x .name , ' metrics_graphite_worker' ) end ):
234+ length ()
235+ end
236+
237+ t .assert_equals (count_workers (), 0 )
238+
239+ graphite .init ({})
240+
241+ t .assert_equals (count_workers (), 1 )
242+
243+ graphite .init ({})
244+
245+ t .assert_equals (count_workers (), 1 )
246+
247+ graphite .stop ()
248+ t .assert_equals (count_workers (), 0 )
249+ end )
250+ end
You can’t perform that action at this time.
0 commit comments