summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/fax_daemon.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-12 13:53:28 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-12 13:53:28 +0100
commitc9066760fd1f5f2f892ce2be5cf2a83bb5210246 (patch)
tree82ecdd528e803ccd1b469dc13482e06cf8ea0b8e /misc/freeswitch/scripts/fax_daemon.lua
parent0b97717b2171820dea41de8df705f8f0e4b71464 (diff)
parentfb66a5e5a4c5d5f9eac4a5e8de6a286482cb55d5 (diff)
Release a new beta.5.1-beta4
Diffstat (limited to 'misc/freeswitch/scripts/fax_daemon.lua')
-rw-r--r--misc/freeswitch/scripts/fax_daemon.lua43
1 files changed, 21 insertions, 22 deletions
diff --git a/misc/freeswitch/scripts/fax_daemon.lua b/misc/freeswitch/scripts/fax_daemon.lua
index 94d343a..0784890 100644
--- a/misc/freeswitch/scripts/fax_daemon.lua
+++ b/misc/freeswitch/scripts/fax_daemon.lua
@@ -5,38 +5,37 @@
local MAIN_LOOP_SLEEP_TIME = 30;
-- Set logger
-require "common.log"
+require 'common.log'
local log = common.log.Log:new()
-log.prefix = "### [faxdaemon] "
+log.prefix = '#F# [faxdaemon] '
-log:debug('Starting fax daemon');
+log:info('FAX_DAEMON start');
-local database = nil;
-local api = freeswitch.API();
+require 'common.database'
+local database = common.database.Database:new{ log = log }:connect();
+if not database:connected() then
+ log:error('FAX_DAEMON - cannot connect to Gemeinschaft database');
+ return;
+end
+local api = freeswitch.API();
+require 'dialplan.fax'
freeswitch.setGlobalVariable('gs_fax_daemon', 'true');
+
while freeswitch.getGlobalVariable("gs_fax_daemon") == 'true' do
- require 'common.database'
- local database = common.database.Database:new{ log = log }:connect();
-
- if not database:connected() then
- log:error("connection to Gemeinschaft database lost - retry in " .. MAIN_LOOP_SLEEP_TIME .. " seconds")
- else
- require 'dialplan.fax'
- local fax_documents = dialplan.fax.Fax:new{log=log, database=database}:queued_for_sending();
-
- for key, fax_document in pairs(fax_documents) do
- if table.getn(fax_document.destination_numbers) > 0 and tonumber(fax_document.retry_counter) > 0 then
- log:debug('FAX_DAEMON_LOOP - fax_document=', fax_document.id, '/', fax_document.uuid, ', number: ' .. fax_document.destination_numbers[1]);
- local result = api:executeString('luarun send_fax.lua ' .. fax_document.id);
- end
+ local fax_documents = dialplan.fax.Fax:new{log=log, database=database}:queued_for_sending();
+
+ for key, fax_document in pairs(fax_documents) do
+ if table.getn(fax_document.destination_numbers) > 0 and tonumber(fax_document.retry_counter) > 0 then
+ log:debug('FAX_DAEMON_LOOP - fax_document=', fax_document.id, '/', fax_document.uuid, ', number: ' .. fax_document.destination_numbers[1]);
+ local result = api:executeString('luarun send_fax.lua ' .. fax_document.id);
end
end
- database:release();
-
+
if freeswitch.getGlobalVariable("gs_fax_daemon") == 'true' then
freeswitch.msleep(MAIN_LOOP_SLEEP_TIME * 1000);
end
end
-log:debug('Exiting fax daemon');
+database:release();
+log:info('FAX_DAEMON exit');