mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-04 18:53:49 +00:00
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
|
||||
|
||||
function EventConsumer:run()
|
||||
function EventConsumer:_run()
|
||||
self._running = true
|
||||
|
||||
-- set some huge default interval
|
||||
@@ -540,6 +540,18 @@ function EventConsumer:run()
|
||||
self._running = false
|
||||
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()
|
||||
self._running = false
|
||||
if self._pid_file and self:_check_pid_file() then
|
||||
|
||||
Reference in New Issue
Block a user