diff --git a/resources/install/scripts/resources/functions/event_consumer.lua b/resources/install/scripts/resources/functions/event_consumer.lua index dd4de925ec..b09b24b5bb 100644 --- a/resources/install/scripts/resources/functions/event_consumer.lua +++ b/resources/install/scripts/resources/functions/event_consumer.lua @@ -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