summaryrefslogtreecommitdiff
path: root/misc/freeswitch
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-05 12:41:26 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-05 12:41:26 +0100
commit4cfc68e3aa5cf1abbdbbbc8dd57fd56b5feb90bf (patch)
tree15d9f5c2b5e6c30668ab69e9de9b248fb547dfdd /misc/freeswitch
parent1c2d8375d32cda0d7819322b165a8270c6500ee9 (diff)
parent676eab5ba9c2a542b9a86e1d9665cdcd7ece9cac (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc/freeswitch')
-rw-r--r--misc/freeswitch/scripts/event/event.lua29
-rw-r--r--misc/freeswitch/scripts/event_manager.lua19
2 files changed, 34 insertions, 14 deletions
diff --git a/misc/freeswitch/scripts/event/event.lua b/misc/freeswitch/scripts/event/event.lua
index 08d8bfe..c98b534 100644
--- a/misc/freeswitch/scripts/event/event.lua
+++ b/misc/freeswitch/scripts/event/event.lua
@@ -27,18 +27,26 @@ function EventManager.register(self)
end
-function EventManager.load_event_modules(self)
- require 'common.configuration_table'
- self.config = common.configuration_table.get(self.database, 'events');
+function EventManager.load_event_modules(self, modules)
+ local event_modules = {};
+
+ for module_name, index in pairs(modules) do
+ if tonumber(index) and index > 0 then
+ event_modules[index] = module_name;
+ self.log:debug('[event] EVENT_MANAGER - enabled handler module: ', module_name);
+ else
+ self.log:debug('[event] EVENT_MANAGER - disabled handler module: ', module_name);
+ end
+ end
- return self.config.modules;
+ return event_modules;
end
function EventManager.load_event_handlers(self, event_modules)
event_handlers = {}
-
- for event_module_name, index in pairs(event_modules) do
+ for index, event_module_name in ipairs(event_modules) do
+ package.loaded['event.' .. event_module_name] = nil;
event_module = require('event.' .. event_module_name);
if event_module then
self.log:info('[event] EVENT_MANAGER - loading handler module: ', event_module_name);
@@ -71,8 +79,12 @@ end
function EventManager.run(self)
+ require 'common.configuration_table'
+ self.config = common.configuration_table.get(self.database, 'events');
+
+ local event_modules = self:load_event_modules(self.config.modules);
+ self.log:info('[event] EVENT_MANAGER_START - handler modules: ', #event_modules);
- local event_modules = self:load_event_modules();
local event_handlers = self:load_event_handlers(event_modules);
if not event_handlers then
@@ -104,4 +116,7 @@ function EventManager.run(self)
end
end
end
+
+ self.consumer = nil;
+ self.log:info('[event] EVENT_MANAGER_EXIT - action: ', freeswitch.getGlobalVariable('gs_event_manager'));
end
diff --git a/misc/freeswitch/scripts/event_manager.lua b/misc/freeswitch/scripts/event_manager.lua
index 1e61baf..3d558e5 100644
--- a/misc/freeswitch/scripts/event_manager.lua
+++ b/misc/freeswitch/scripts/event_manager.lua
@@ -7,12 +7,12 @@ require "common.log"
local log = common.log.Log:new()
log.prefix = "#E# "
-log:info('[event] EVENT_MANAGER start');
+log:info('[event] EVENT_MANAGER_LOADER start');
require 'common.database'
local database = common.database.Database:new{ log = log }:connect();
if not database:connected() then
- log:error('[event] EVENT_MANAGER - cannot connect to Gemeinschaft database');
+ log:error('[event] EVENT_MANAGER_LOADER - cannot connect to Gemeinschaft database');
return;
end
@@ -23,16 +23,21 @@ local domain = '127.0.0.1';
if domains[1] then
domain = domains[1]['host'];
else
- log:error('[event] EVENT_MANAGER - No SIP domains found!');
+ log:error('[event] EVENT_MANAGER_LOADER - No SIP domains found!');
end
-require 'event.event'
-local event_manager = event.event.EventManager:new{ log = log, database = database, domain = domain }
-event_manager:run();
+freeswitch.setGlobalVariable('gs_event_manager', 'true');
+while freeswitch.getGlobalVariable('gs_event_manager') ~= 'false' do
+ package.loaded['event.event'] = nil;
+ local manager_class = require('event.event');
+ local event_manager = manager_class.EventManager:new{ log = log, database = database, domain = domain }
+ freeswitch.setGlobalVariable('gs_event_manager', 'true');
+ event_manager:run();
+end
-- ensure database handle is released on exit
if database then
database:release();
end
-log:info('[event] EVENT_MANAGER exit');
+log:info('[event] EVENT_MANAGER_LOADER exit');