Add. Basic fax_queue_monitor script.

To start
 From cli: `luarun fax_queue_monitor.lua`
 Autostart with FS: Add `<param name="startup-script" value="fax_queue_monitor.lua"/>` to `lua.conf.xml`
 From shell: call from `script_dir` `lua fax_queue_monitor.lua` (require installed Lua and some additional libraries).

To stop
  remove `fax_queue.tmp` file from `script_dir/run`
This commit is contained in:
Alexey Melnichuk 2015-11-19 13:19:59 +03:00
parent 18574dfe8b
commit 6f46b72dc8
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
local sleep_interval = 60;
--include config.lua
require "resources.functions.config";
--general functions
require "resources.functions.file_exists";
require "resources.functions.mkdir";
require "resources.functions.sleep";
local log = require "resources.functions.log".fax_queue_monitor
local Next = require "fax_queue.next"
mkdir(scripts_dir .. "/run");
--define the run file
local run_file = scripts_dir .. "/run/fax_queue.tmp";
--used to stop the lua service
local file = assert(io.open(run_file, "w"));
file:write("remove this file to stop the script");
file:close()
log.notice("Start")
while true do
local ok, err = pcall(function()
Next.poll_once()
end)
if not ok then
log.errf("fail poll queue: %s", tostring(err))
end
if not file_exists(run_file) then
break;
end
sleep(sleep_interval * 1000)
end
log.notice("Stop")