Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile.s6-overlay
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
procmail \
python3 \
python3-dev \
rsyslog \
strace \
vim \
wget \
Expand All @@ -102,6 +103,8 @@ RUN sed -i "s/rlimit-nproc=3//" /etc/avahi/avahi-daemon.conf
COPY src/htoprc /root/.config/htop/
COPY src/mdns.allow /etc/mdns.allow
COPY src/nsswitch.conf /etc/nsswitch.conf
COPY src/rsyslog.conf /etc/rsyslog.conf
COPY src/rsyslog.d/ /etc/rsyslog.d/

# Directory where rendered environment files are stored
RUN mkdir /balena
Expand Down
34 changes: 34 additions & 0 deletions src/rsyslog.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

global(
workDirectory="/var/spool/rsyslog"
)

# Load the input modules for system and kernel logging.
# module(load="imuxsock") # Local system logs (e.g., from journald)
# module(load="imklog") # Kernel log capture

module(load="imfile"
readTimeout="500" # Sets the multi-line read timeout in seconds
)

# Custom template for 'noTimestampFormat' format
template(name="noTimestampFormat" type="string"
string="%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
)

# Extract service name and PID from filename pattern: {service}.log.{pid}
set $!service = re_extract($!metadata!filename, ".*/([^/]+)\\.log\\.([0-9]+)", 0, 1, "system");
set $!pid = re_extract($!metadata!filename, ".*/([^/]+)\\.log\\.([0-9]+)", 0, 2, "0");

# Format with both service and PID info
template(name="ServiceWithPID" type="string"
string="%$!service%[%$!pid%]:%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n")

# Output all messages to stdout
action(type="omfile"
file="/dev/stdout"
template="ServiceWithPID"
)

# Include any additional configuration files
include(file="/etc/rsyslog.d/*.conf")
6 changes: 6 additions & 0 deletions src/rsyslog.d/avahi-daemon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

input(type="imfile"
File="/run/avahi-daemon.log.*"
Tag=""
readMode="2" # indented (lines starting with a space or tab belong to the previous message)
)
6 changes: 6 additions & 0 deletions src/rsyslog.d/dbus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

input(type="imfile"
File="/run/dbus.log.*"
Tag=""
readMode="2" # indented (lines starting with a space or tab belong to the previous message)
)
4 changes: 2 additions & 2 deletions src/s6-overlay/s6-rc.d/avahi-daemon/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

set -euo pipefail

# Redirect all future stdout/stderr to s6-log
exec > >(exec s6-log -b p"avahi-daemon[$$]:" 1 || true) 2>&1
# This will be picked up by rsyslog and output to stdout
exec > "/run/avahi-daemon.log.$$" 2>&1

# Wait for dbus
count=0
Expand Down
3 changes: 1 addition & 2 deletions src/s6-overlay/s6-rc.d/certs-watch/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# Watch /certs directory for changes and restart confd service when detected
# Uses inotifywait to monitor for modifications in the /certs directory

# Redirect all future stdout/stderr to s6-log
exec > >(exec s6-log -b p"certs-watch[$$]:" 1 || true) 2>&1
exec 2>&1

# Create /certs directory if it doesn't exist
mkdir -p /certs
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions src/s6-overlay/s6-rc.d/dbus/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -euo pipefail

# Redirect all future stdout/stderr to s6-log
exec > >(exec s6-log -b p"dbus[$$]:" 1 || true) 2>&1
# This will be picked up by rsyslog and output to stdout
exec > "/run/dbus.log.$$" 2>&1

mkdir -p /run/dbus

Expand Down
Empty file.
7 changes: 7 additions & 0 deletions src/s6-overlay/s6-rc.d/rsyslog/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

exec 2>&1

exec rsyslogd -n -f /etc/rsyslog.conf
1 change: 1 addition & 0 deletions src/s6-overlay/s6-rc.d/rsyslog/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 1 addition & 2 deletions src/s6-overlay/scripts/confd-up.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/command/with-contenv bash
# shellcheck shell=bash

# Redirect all future stdout/stderr to s6-log
exec > >(exec s6-log -b p"confd[$$]:" 1 || true) 2>&1
exec 2>&1

# Populate /etc/docker.env with all container environment variables
for var in $(compgen -e); do
Expand Down
Loading