-- ********************************************************************** local qroot = "webapps/queue/" require (qroot.."api/compat-5.1") package.path = qroot.."api/?.lua" package.cpath = qroot.."api/?.dll" -- ********************************************************************** require "fileutils" -- global queuePath = qroot.."queue" procPath = qroot.."process" classes = { "ALPHA", "BETA", "GAMMA", "DELTA", } ------------------------------------------------------------------------- function qwrite(p,pp) local q = queuePath.."/"..p.class.."."..p.process local msg = "\n"..string.upper(pp or p.command or "INIT").."\t "..tostring(os.date()).."\t " prm = "" table.foreach(p, function(k,v) if string.upper(k)~="CLASS" and string.upper(k)~="PROCESS" and string.upper(k)~="COMMAND" then prm = prm..tostring(v).." " end end) file.append(q,msg..prm) end ------------------------------------------------------------------------- function LUNAAPI_GET(requestheader,requestdata) -- return queue item if file.exists(queuePath..tostring(requestheader.document)) then return file.tohtml(queuePath..requestheader.document) -- do process elseif requestdata and requestdata.class and string.find(table.concat(classes,","),string.upper(requestdata.class)) then if file.exists(procPath.."/"..tostring(requestdata.process)) then -- default ok, any override? if file.exists(procPath.."/"..requestdata.class.."/"..requestdata.process) then dofile(procPath.."/"..requestdata.class.."/"..requestdata.process) getfenv()[string.lower(requestdata.command or "init")](requestdata) return "Process exec: "..requestdata.class.."."..requestdata.process else dofile(procPath.."/"..requestdata.process) getfenv()[string.lower(requestdata.command or "init")](requestdata) return "Process exec: ".."default."..requestdata.process end else return "Process error: "..tostring(requestdata.process) end -- error else return {filename=qroot.."index.html"} end end ------------------------------------------------------------------------- function LUNAAPI_POST(requestheader,requestdata) return LUNAAPI_GET(requestheader,requestdata) end -- LUNAAPI_POST({},{class="alpha",process="load"})