Fix. Properly stop (e.g. remove pid file) event consumer loop in case of error. (#1766)
This commit is contained in:
committed by
FusionPBX
parent
1279c80d8a
commit
207cf08e88
@@ -501,7 +501,7 @@ function EventConsumer:bind(event_name, cb)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function EventConsumer:run()
|
function EventConsumer:_run()
|
||||||
self._running = true
|
self._running = true
|
||||||
|
|
||||||
-- set some huge default interval
|
-- set some huge default interval
|
||||||
@@ -540,6 +540,18 @@ function EventConsumer:run()
|
|||||||
self._running = false
|
self._running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EventConsumer:run()
|
||||||
|
local ok, err = xpcall(function()
|
||||||
|
self:_run()
|
||||||
|
end, debug.traceback)
|
||||||
|
|
||||||
|
if not ok then
|
||||||
|
-- ensure we stop loop and remove pid file
|
||||||
|
self:stop()
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function EventConsumer:stop()
|
function EventConsumer:stop()
|
||||||
self._running = false
|
self._running = false
|
||||||
if self._pid_file and self:_check_pid_file() then
|
if self._pid_file and self:_check_pid_file() then
|
||||||
|
|||||||
Reference in New Issue
Block a user