# Systemd template for a supervised timberfs log intake (see timberfs-log@.socket).
#
# Drains the instance's FIFO (passed as stdin by the socket unit) into a store
# at /var/log/timberfs/<instance>/<instance>.log. Each instance gets its own
# directory so it can be owned and managed independently (see LogsDirectory
# below). The producer must write a timberfs-records(5) stream (that is what
# --records means); to archive a plain-text source instead, drop --records from
# ExecStart. Override the store path, add retention, or change the format with a
# drop-in:
#
# systemctl edit timberfs-log@applogs.service
# [Service]
# ExecStart=
# ExecStart=/usr/bin/timberfs append --records --exit-on-upgrade --into /srv/logs/applogs.log --retain 30d
#
# This is socket-activated: enable the .socket, not this unit. The first write
# starts it and Restart=always keeps it up; a restart or upgrade is invisible to
# the producer because the socket holds the FIFO open across it.
[Unit]
Description=timberfs log intake (%i)
Documentation=https://github.com/torstei/timberfs
Requires=timberfs-log@%i.socket
After=timberfs-log@%i.socket
[Service]
Type=simple
ExecStart=/usr/bin/timberfs append --records --exit-on-upgrade --into /var/log/timberfs/%i/%i.log
StandardInput=socket
StandardOutput=journal
StandardError=journal
# Creates and owns the per-instance directory /var/log/timberfs/%i (0755) —
# where this instance's .trunk/.rings/.bark live. A drop-in that sets User=
# gets that dir owned by that user, so each instance is independently owned
# and manageable (indexing, rotation) without a directory shared across all.
LogsDirectory=timberfs/%i
# A crash or upgrade of this unit is invisible to the producer (the socket holds
# the FIFO open): come back and keep draining.
Restart=always
RestartSec=1
# --exit-on-upgrade: the daemon exits 85 when its binary is upgraded on disk;
# force a restart onto the new binary. The socket holds the FIFO open across
# it, so the producer sees no gap. SuccessExitStatus keeps it out of the
# failure log. (Keep --exit-on-upgrade in any ExecStart override.)
SuccessExitStatus=85
RestartForceExitStatus=85
# No [Install] section: this is socket-activated. Enable the .socket.