commit 70786712b3064a28da5cda7e34f29202ef46fb96 parent be26df4e95a60704b7918951d35387d8ea58bcab Author: Daniel Barlow <dan@telent.net> Date: Wed, 8 Oct 2025 19:42:19 +0100 make victorialogsend ucspi-compatible Diffstat:
| M | pkgs/logshippers/victorialogsend.fnl | | | 18 | +++++++++++++----- |
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/pkgs/logshippers/victorialogsend.fnl b/pkgs/logshippers/victorialogsend.fnl @@ -72,14 +72,22 @@ Host: %s\ :_msg msg :host hostname) chunk))) +(fn writefd [fd body] + (case (ll.write fd body) + (bytes) (when (< bytes (# body)) (writefd fd (string.sub body bytes))) + (nil errno) + (error (string.format "write to fd %d failed: %s" fd (ll.strerror errno)))) + true) (fn run [] - (let [{ : auth : url } (parse-args arg)] - (ll.write 1 (http-header url.host url.path auth)) + (let [{ : auth : url } (parse-args arg) + in-fd 6 + out-fd 7] + (writefd out-fd (http-header url.host url.path auth)) (while (case (io.stdin:read "l") - line (ll.write 1 (process-line line)))) - (ll.write 1 (chunk ""))) - (io.stderr:write (ll.read 0))) + line (writefd out-fd (process-line line)))) + (writefd out-fd (chunk "")) + (io.stderr:write (ll.read in-fd)))) { : run }