This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Best way for synchronize objects on LMs
#2
Hi
Yes objects must  be exported.
You can make an LP file which would read all the objects and on another LM script which would read it from other LM and update its DB.

Here is example which will sync scheduler and scenes done for redundancy operation. You can modify.

Master LP
Code:
<? require('apps') result = {} tables = {   'scenes', 'scene_tags', 'scene_sequence',   'schedulers', 'scheduler_events', 'scheduler_holidays' } for _, tname in ipairs(tables) do   result[ tname ] = db:getall('SELECT * FROM ' .. tname) end json.write(result)

Slave script

Code:
json = require('json') http = require('socket.http') function clearschedulers()   local files = io.ls('/tmp')   for _, file in ipairs(files) do     if file:find('lm-scheduler-', 1, true) then       os.remove('/tmp/' .. file)     end   end end function import(data)  for tname, rows in pairs(data) do    db:query('DELETE FROM ' .. tname)    for _, row in ipairs(rows) do      db:insert(tname, row)    end  end  scene.reload()  clearschedulers() end data = http.request('http://admin:admin@192.168.1.12/user/redundancy.lp') if data then   data = json.pdecode(data)   if type(data) == 'table' then     import(data)   end end
------------------------------
Ctrl+F5
Reply


Messages In This Thread
RE: Best way for synchronize objects on LMs - by Daniel - 26.10.2018, 13:13

Forum Jump: