Last active
December 14, 2016 11:49
-
-
Save moteus/f18b8a75bdc705e3901f83a168b8798b to your computer and use it in GitHub Desktop.
FusionPBX fax_queue_monitor based on EventCounsumer class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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