From c69916c53c32c58519fbf8d40ccc3c4bc987e05a Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Thu, 25 Aug 2022 09:18:54 -0600 Subject: [PATCH] Fix GoDoc comment formatting --- cache-config/t3c-apply/torequest/cmd.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cache-config/t3c-apply/torequest/cmd.go b/cache-config/t3c-apply/torequest/cmd.go index 85855d46d0..cf8f8757b3 100644 --- a/cache-config/t3c-apply/torequest/cmd.go +++ b/cache-config/t3c-apply/torequest/cmd.go @@ -291,9 +291,21 @@ func sendUpdate(cfg config.Cfg, configApplyTime, revalApplyTime *time.Time, conf return nil } -//doTail calls t3c-tail and will run a tail on the log file provided with string for a regex to -//maatch on default is .* endMatch will make t3c-tail exit when a pattern is matched otherwise -//a timeout in a given number of seconds will occur. +// doTail calls t3c-tail, which will read lines from the file at the provided +// path, and will print lines matching the 'logMatch' regular expression. +// When a line matching the 'endMatch' regular expression is encountered, +// t3c-tail will exit - which means it MUST NOT be an empty string or only the +// first line of the file will ever be read (and possibly printed, if it matches +// 'logMatch'). In any case, the process will terminate after 'timeoutInMS' +// milliseconds. +// Note that apart from an exit code difference on timeout, this is almost +// exactly equivalent to the bash command: +// +// timeout timeoutInS tail -fn+2 file | grep -m 1 -B "$(wc -l file | cut -d ' ' -f1)" -E endMatch | grep -E logMatch +// +// ... where 'timeoutInS' is 1/1000 of 'timeoutInMS' and the string values of +// arguments are otherwise substituted wherever they are found (GNU coreutils +// are assumed to be present). func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeoutInMS int) error { args := []string{ "--file=" + filepath.Join(cfg.TsHome, file), @@ -302,8 +314,8 @@ func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeo "--timeout-ms=" + strconv.Itoa(timeoutInMS), } stdOut, stdErr, code := t3cutil.Do(`t3c-tail`, args...) - if code > 1 { - return fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) + if code >= 1 { + return fmt.Errorf("t3c-tail returned error code %d stdout '%s' stderr '%s'", code, stdOut, stdErr) } logSubApp(`t3c-tail`, stdErr)