From de251392fffd63bae7e586b9cf7a7991c30195ff Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 8 Feb 2010 19:42:00 +0100 Subject: beta 2010.02.08 19:42 --- scripts/context/lua/mtx-watch.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua index fa4cd0eab..33dc08928 100644 --- a/scripts/context/lua/mtx-watch.lua +++ b/scripts/context/lua/mtx-watch.lua @@ -12,6 +12,11 @@ scripts.watch = scripts.watch or { } local format, concat, difftime, time = string.format, table.concat, os.difftime, os.time local pairs, ipairs, next, type = pairs, ipairs, next, type +-- the machine/instance matches the server app we use + +local machine = socket.dns.gethostname() or "unknown-machine" +local instance = string.match(machine,"(%d+)$") or "0" + function scripts.watch.save_exa_modes(joblog,ctmname) local values = joblog and joblog.values if values then @@ -78,13 +83,20 @@ function scripts.watch.watch() local logpath = environment.argument("logpath") or "" local pipe = environment.argument("pipe") or false local watcher = "mtxwatch.run" - if #environment.files > 0 then - for _, path in ipairs(environment.files) do + local paths = environment.files + if #paths > 0 then + if environment.argument("automachine") then + logpath = string.gsub(logpath,"/machine/","/"..machine.."/") + for i, path in ipairs(paths) do + paths[i] = string.gsub(path,"/machine/","/"..machine.."/") + end + end + for _, path in ipairs(paths) do logs.report("watch", "watching path ".. path) end local function process() local done = false - for _, path in ipairs(environment.files) do + for _, path in ipairs(paths) do lfs.chdir(path) local files = { } glob(files,path) @@ -198,7 +210,7 @@ function scripts.watch.watch() local delta = difftime(currenttime,lasttime) if delta > cleanupdelay then lasttime = currenttime - for _, path in ipairs(environment.files) do + for _, path in ipairs(paths) do if string.find(path,"%.") then -- safeguard, we want a fully qualified path else @@ -343,6 +355,7 @@ messages.help = [[ --watch watch given path [--delay] --pipe use pipe instead of execute --delay delay between sweeps +--automachine replace /machine/ in path // --collect condense log files --cleanup=delay remove files in given path [--force] --showlog show log data -- cgit v1.2.3