From 2d3dca99b08505539bed59c30194904f7fafc7b5 Mon Sep 17 00:00:00 2001 From: robsketch Date: Wed, 4 Dec 2024 16:06:08 +0000 Subject: [PATCH 1/2] Add warning if environment variable is not set and improve logging --- torq.q | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/torq.q b/torq.q index 4d9afffa3..dfab9433d 100644 --- a/torq.q +++ b/torq.q @@ -301,7 +301,7 @@ exitifnull:{[variable] \d .rmvr removeenvvar:{ - // positions of {} + // positions of {} pos:ss[x]each"{}"; // check the formatting is ok $[0=count first pos; :x; @@ -310,7 +310,13 @@ removeenvvar:{ ()]; // cut out each environment variable, and retrieve the meaning - raze {$["{"=first x;getenv`$1 _ -1 _ x;x]}each (raze flip 0 1+pos) cut x} + // ascertain if string is an env var by checking if first char is a { + raze {$["{"~first x;resolveandcheckenvvar[x];x]}each (raze flip 0 1+pos) cut x} + +resolveandcheckenvvar:{[s] + ev:getenv[`$1 _ -1 _ s]; + if[""~ev;.lg.w[`resolveandcheckenvvar;"warning, could not resolve environment variable: ",s]]; + ev} // Process initialisation \d .proc @@ -426,14 +432,14 @@ readprocfile:{[file] .err.ex[`readprocfile;"Current host does not match host specified in ",string[file],". Parameters are host: ", string[output`host], ", port: ", string[output`port], ", proctype: ", string[output`proctype], ", procname: ",string output`procname;1]]; // exit if no port passed via command line or specified in config if[null[output`port]&0i=system"p"; - .err.ex[`readprocfile;"No port passed via -p flag or found in ",string[file],". Parameters are host: ", string[output`host], ", proctype: ", string[output`proctype], ", procname: ",string output`procname;1]]; + .err.ex[`readprocfile;"No port number passed via -p flag or no port number found in ",string[file],". Parameters are host: ", string[output`host], ", proctype: ", string[output`proctype], ", procname: ",string output`procname;1]]; // .finspace.enabled flag here is a temporarily bug fix for Finspace DEV clusters - port is set later so is empty when we reach this point. AWS investigating if[not[.finspace.enabled]¬[output[`port] = system"p"]& 0i = system"p"; @[system;"p ",string[output[`port]];.err.ex[`readprocfile;"failed to set port to ",string[output[`port]]]]; .lg.o[`readprocfile;"port set to ",string[output[`port]]] ]; output - } + } .lg.o[`init;"attempting to read required process parameters ",("," sv string req)," from file ",string file]; // Read in the file, pull out the rows which are applicable and set the local variables From 9b660d6662232cc9833322bbf75bcdbbe1e8ca86 Mon Sep 17 00:00:00 2001 From: robsketch Date: Wed, 4 Dec 2024 16:30:53 +0000 Subject: [PATCH 2/2] Remove rmvr common file as the functions are defined in main torq script --- code/common/rmvr.q | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 code/common/rmvr.q diff --git a/code/common/rmvr.q b/code/common/rmvr.q deleted file mode 100644 index c4b509d0f..000000000 --- a/code/common/rmvr.q +++ /dev/null @@ -1,15 +0,0 @@ -\d .rmvr - -//function for replacing environment variables with the associated full path. - -removeenvvar:{ - // positions of {} - pos:ss[x]each"{}"; - // check the formatting is ok - $[0=count first pos; :x; - 1pos[1]) or any pos[0]