Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FusionPBX fax_queue_monitor based on EventCounsumer class
require "resources.functions.config"
require "resources.functions.split"
local log = require "resources.functions.log".fax_queue_monitor
local Next = require "app.fax.resources.scripts.queue.next"
local EventConsumer = require "resources.functions.event_consumer"
local pid_file = scripts_dir .. "/run/fax_queue.tmp"
local events = EventConsumer.new(pid_file)
-- FS shutdown
events:bind("SHUTDOWN", function(self, name, event)
log.notice("shutdown")
return self:stop()
end)
-- shutdown command
events:bind("CUSTOM::fusion::fax::shutdown", function(self, name, event)
log.notice("shutdown")
return self:stop()
end)
-- timeout
events:onInterval(60000, function(self)
local ok, err = pcall(function()
Next.poll_once()
end)
if not ok then
log.errf("fail poll queue: %s", tostring(err))
end
end)
log.notice("start")
events:run()
log.notice("stop")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.