From 70786712b3064a28da5cda7e34f29202ef46fb96 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Wed, 8 Oct 2025 19:42:19 +0100 Subject: [PATCH] make victorialogsend ucspi-compatible --- pkgs/logshippers/victorialogsend.fnl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/logshippers/victorialogsend.fnl b/pkgs/logshippers/victorialogsend.fnl index fb6e1f0..0f989e6 100644 --- 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 }