diff options
Diffstat (limited to 'nopsyncd/qlistener.lua')
-rwxr-xr-x | nopsyncd/qlistener.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/nopsyncd/qlistener.lua b/nopsyncd/qlistener.lua index 2ebf5be..9498fbb 100755 --- a/nopsyncd/qlistener.lua +++ b/nopsyncd/qlistener.lua @@ -22,6 +22,7 @@ local queue_name = "/rhnop" mq = require "luamq" +db = require "db" function main_loop() local q, err = mq.create(queue_name, "ro") @@ -30,6 +31,12 @@ function main_loop() os.exit(1) end + local ret, err = db:init() + if ret == nil then + io.stderr:write("creation of db failed: " .. err .. "\n") + os.exit(1) + end + while true do local msg, prio = mq.receive(q) if msg == nil then @@ -37,9 +44,13 @@ function main_loop() os.exit(2) end - -- TODO: lookup info in Rivendell DB and insert into temporary storage - print("received message '" .. msg .. "' with prio: " .. prio) - - pipe.signal() + local timestamp, nowcart, nowlen, nextcart, nextlen = string.match(msg, "^(%d+) (%d+) (%d+) (%d+) (%d+)$"); + if not timestamp or not nowcart or not nowlen or not nextcart or not nextlen then + io.stderr:write("ignoring malformed message\n") + else + -- TODO: lookup info in Rivendell DB and insert into temporary storage + print("received message:\ntimestamp = " .. timestamp .. "\nnowcart = " .. nowcart .. "\nnowlen = " .. nowlen .. "\nnextcart = " .. nextcart .. "\nnextlen = " .. nextlen) + pipe.signal() + end end end
\ No newline at end of file |