log.shipping.command is now a command not a string
This commit is contained in:
@@ -239,10 +239,12 @@ in
|
||||
shipping = {
|
||||
enable = mkEnableOption "fifo for log shipping";
|
||||
command = mkOption {
|
||||
description = "log shipping command, should open the file named by the environment variable $LOG_FIFO";
|
||||
type = types.lines;
|
||||
description = "log shipping command, should accept one parmeter which is the file name to read";
|
||||
type = types.pathInStore;
|
||||
example = lib.literalExpression ''
|
||||
writeAshScript "shipper" {} \'\'
|
||||
''${pkgs.s6-networking}/bin/s6-tcpclient loghost 9428 ''${pkgs.logshippers}/bin/victorialogsend http://loghost:9428/insert/jsonline
|
||||
\'\'
|
||||
'';
|
||||
};
|
||||
dependencies = mkOption {
|
||||
@@ -270,10 +272,7 @@ in
|
||||
mkIf config.logging.shipping.enable (
|
||||
longrun {
|
||||
name = "log-shipper";
|
||||
run = ''
|
||||
export LOG_FIFO=${fifo}
|
||||
${cfg.command}
|
||||
'';
|
||||
run = "${cfg.command} ${fifo}";
|
||||
inherit (config.logging.shipping) dependencies;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
["--basic-auth" auth & rest]
|
||||
(assoc (parse-args rest) :auth auth)
|
||||
|
||||
[url] { :url (parse-url url) }
|
||||
[fifo url] { :fifo fifo :url (parse-url url) }
|
||||
_ (error "invalid args")))
|
||||
|
||||
|
||||
@@ -87,11 +87,11 @@ Host: %s\
|
||||
true)
|
||||
|
||||
(fn run []
|
||||
(let [{ : auth : url } (parse-args arg)
|
||||
(let [{ : auth : url : fifo } (parse-args arg)
|
||||
http-response-fd 6
|
||||
http-req-fd 7]
|
||||
(writefd http-req-fd (http-header url.host url.path auth))
|
||||
(with-open [logs (assert (io.open (os.getenv "LOG_FIFO") :r))]
|
||||
(with-open [logs (assert (io.open fifo :r))]
|
||||
(while (case (logs:read "l")
|
||||
line (writefd http-req-fd (process-line line)))))
|
||||
(writefd http-req-fd (chunk ""))
|
||||
|
||||
Reference in New Issue
Block a user