26.10.2018, 13:13
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
Slave script
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
Ctrl+F5