Update local_stream.conf.lua

This commit is contained in:
FusionPBX 2018-01-11 12:07:40 -07:00 committed by GitHub
parent 929b79d5d0
commit d38aa31031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 131 additions and 86 deletions

View File

@ -1,8 +1,32 @@
--get the cache
local cache = require "resources.functions.cache"
local local_stream_cache_key = "configuration:local_stream.conf"
XML_STRING, err = cache.get(local_stream_cache_key)
--set the cache
if not XML_STRING then
--log the cache error
if (debug["cache"]) then
freeswitch.consoleLog("warning", "[xml_handler] configuration:local_stream.conf can not be get from cache: " .. tostring(err) .. "\n");
end
--set a default value
if (expire["default"] == nil) then
expire["default"]= "3600";
end
--connect to the database
local Database = require "resources.functions.database";
dbh = Database.new('system');
--include json library
local json
if (debug["sql"]) then
json = require "resources.functions.lunajson"
end
--exits the script if we didn't connect properly
assert(dbh:connected());
@ -97,6 +121,27 @@
--close the database connection
dbh:release();
--set the cache
local ok, err = cache.set(local_stream_cache_key, XML_STRING, expire["default"]);
if debug["cache"] then
if ok then
freeswitch.consoleLog("notice", "[xml_handler] " .. local_stream_cache_key .. " stored in the cache\n");
else
freeswitch.consoleLog("warning", "[xml_handler] " .. local_stream_cache_key .. " can not be stored in the cache: " .. tostring(err) .. "\n");
end
end
--send to the console
if (debug["cache"]) then
freeswitch.consoleLog("notice", "[xml_handler] " .. local_stream_cache_key .. " source: database\n");
end
else
--send to the console
if (debug["cache"]) then
freeswitch.consoleLog("notice", "[xml_handler] " .. local_stream_cache_key .. " source: cache\n");
end
end --if XML_STRING
--send the xml to the console
if (debug["xml_string"]) then
local file = assert(io.open(temp_dir .. "/local_stream.conf.xml", "w"));