Update local_stream.conf.lua
This commit is contained in:
parent
929b79d5d0
commit
d38aa31031
|
|
@ -1,19 +1,43 @@
|
|||
|
||||
--connect to the database
|
||||
--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');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
--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());
|
||||
|
||||
--start the xml array
|
||||
--start the xml array
|
||||
local xml = {}
|
||||
table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
||||
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
||||
table.insert(xml, [[ <section name="configuration">]]);
|
||||
table.insert(xml, [[ <configuration name="local_stream.conf" description="stream files from local dir">]]);
|
||||
|
||||
--run the query
|
||||
--run the query
|
||||
sql = "select d.domain_name, s.* "
|
||||
sql = sql .. "from v_music_on_hold as s left outer join v_domains as d "
|
||||
sql = sql .. "on d.domain_uuid = s.domain_uuid "
|
||||
|
|
@ -85,7 +109,7 @@
|
|||
|
||||
end)
|
||||
|
||||
--close the extension tag if it was left open
|
||||
--close the extension tag if it was left open
|
||||
table.insert(xml, [[ </configuration>]]);
|
||||
table.insert(xml, [[ </section>]]);
|
||||
table.insert(xml, [[</document>]]);
|
||||
|
|
@ -94,9 +118,30 @@
|
|||
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
|
||||
end
|
||||
|
||||
--close the database connection
|
||||
--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"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue