From 624a33a61ea956662ce86b9279ad625bda9fbc7c Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 4 Jun 2025 19:23:45 +0000 Subject: [PATCH] Use static binary from official mtail release instead of Debian package Debian has outdated version that does not actually work with logs from stdin. It gets stuck after some time. --- cmdeploy/src/cmdeploy/__init__.py | 23 +++++++++++++++++++- cmdeploy/src/cmdeploy/mtail/mtail.service.j2 | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index f6a0b4b6..ad8c72b9 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -457,9 +457,30 @@ def check_config(config): def deploy_mtail(config): + # Uninstall mtail package, we are going to install a static binary. apt.packages( - name="Install mtail", + name="Uninstall mtail", packages=["mtail"], + present=False + ) + + (url, sha256sum) = { + "x86_64": ( + "https://github.com/google/mtail/releases/download/v3.0.8/mtail_3.0.8_linux_amd64.tar.gz", + "123c2ee5f48c3eff12ebccee38befd2233d715da736000ccde49e3d5607724e4", + ), + "aarch64": ( + "https://github.com/google/mtail/releases/download/v3.0.8/mtail_3.0.8_linux_arm64.tar.gz", + "aa04811c0929b6754408676de520e050c45dddeb3401881888a092c9aea89cae", + ), + }[host.get_fact(facts.server.Arch)] + + server.shell( + name="Download mtail", + commands=[ + f"(echo '{sha256sum} /usr/local/bin/mtail' | sha256sum -c) || (curl -L {url} | gunzip | tar -x -f - mtail -O >/usr/local/bin/mtail.new && mv /usr/local/bin/mtail.new /usr/local/bin/mtail)", + "chmod 755 /usr/local/bin/mtail", + ], ) # Using our own systemd unit instead of `/usr/lib/systemd/system/mtail.service`. diff --git a/cmdeploy/src/cmdeploy/mtail/mtail.service.j2 b/cmdeploy/src/cmdeploy/mtail/mtail.service.j2 index 3ada023c..42fcaac3 100644 --- a/cmdeploy/src/cmdeploy/mtail/mtail.service.j2 +++ b/cmdeploy/src/cmdeploy/mtail/mtail.service.j2 @@ -3,7 +3,7 @@ Description=mtail [Service] Type=simple -ExecStart=/bin/sh -c "journalctl -f -o short-iso -n 0 | /usr/bin/mtail --address={{ address }} --port={{ port }} --progs /etc/mtail --logtostderr --logs /dev/stdin" +ExecStart=/bin/sh -c "journalctl -f -o short-iso -n 0 | /usr/local/bin/mtail --address={{ address }} --port={{ port }} --progs /etc/mtail --logtostderr --logs -" Restart=on-failure [Install]