mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-03-17 22:12:13 +00:00
File cache sync via curl (#2851)
* Add sendevent when using file caching * Create clear_cache.lua FS receives a command via curl to call this script which deletes the single cache entry or flushes the entire cache. * Create file_cache.lua This scripts monitors for custom events. When an event is processed it will send out a command via curl to other FS servers telling them to clear their cache. This must be called from conf/autoload_configs/lua.conf.xml <param name="startup-script" value="app/server/resources/memcache.lua"/>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
--includes
|
||||
require "resources.functions.config";
|
||||
local Database = require "resources.functions.database";
|
||||
local Settings = require "resources.functions.lazy_settings"
|
||||
dbh = Database.new('system');
|
||||
local settings = Settings.new(dbh, domain_name, domain_uuid);
|
||||
|
||||
|
||||
--define trim
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--get the argv values
|
||||
cmd = argv[1];
|
||||
file = argv[2];
|
||||
|
||||
--get the cache directory
|
||||
local cache_dir = settings:get('cache', 'location', 'text')
|
||||
|
||||
if (cmd ~= nil) then
|
||||
cmd = trim(cmd);
|
||||
freeswitch.consoleLog("NOTICE","api_command: "..cmd .. " cache\n");
|
||||
end
|
||||
|
||||
if (cmd == "flush") then
|
||||
os.execute("rm " .. cache_dir .. "/*");
|
||||
end
|
||||
|
||||
if (cmd == "delete") then
|
||||
if (file ~= nil) then
|
||||
file = trim(file);
|
||||
freeswitch.consoleLog("NOTICE","api_command: delete ".. cache_dir .. "/" .. file .. "\n");
|
||||
os.remove(cache_dir.."/"..file);
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user