Skip to content

Commit

Permalink
package/fluent-bit: add new package
Browse files Browse the repository at this point in the history
Fluent Bit is a super fast, lightweight, and highly
scalable logging and metrics processor and forwarder.

Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
[Peter: add DEVELOPERS entry, drop STATIC_LIBS dependency]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  • Loading branch information
ThomasDevoogdt authored and jacmet committed Jan 27, 2023
1 parent c373ca0 commit 6a0f7c3
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DEVELOPERS
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,9 @@ F: support/testing/tests/package/test_perl_lwp_protocol_https.py
F: utils/size-stats-compare
F: toolchain/

N: Thomas Devoogdt <thomas@devoogdt.com>
F: package/fluent-bit/

N: Thomas Huth <huth@tuxfamily.org>
F: board/qemu/m68k-mcf5208/
F: configs/qemu_m68k_mcf5208_defconfig
Expand Down
1 change: 1 addition & 0 deletions package/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,7 @@ menu "System tools"
source "package/efivar/Config.in"
source "package/embiggen-disk/Config.in"
source "package/emlog/Config.in"
source "package/fluent-bit/Config.in"
source "package/ftop/Config.in"
source "package/getent/Config.in"
source "package/gkrellm/Config.in"
Expand Down
12 changes: 12 additions & 0 deletions package/fluent-bit/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
config BR2_PACKAGE_FLUENT_BIT
bool "fluent-bit"
depends on BR2_TOOLCHAIN_USES_GLIBC
select BR2_PACKAGE_OPENSSL
select BR2_PACKAGE_LIBYAML
help
Fast and Lightweight Logs and Metrics processor.

https://github.com/fluent/fluent-bit

comment "fluent-bit needs a glibc toolchain"
depends on !BR2_TOOLCHAIN_USES_GLIBC
72 changes: 72 additions & 0 deletions package/fluent-bit/S99fluent-bit
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh

DAEMON="fluent-bit"
PID_FILE="/var/run/$DAEMON.pid"
CONF_FILE="/etc/$DAEMON/$DAEMON.conf"

FLUENT_BIT_ARGS=""

# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"

start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -S -q -b -m -p "$PID_FILE" --exec "/usr/bin/$DAEMON" \
-- -c "$CONF_FILE" $FLUENT_BIT_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

stop() {
printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p "$PID_FILE"
status=$?

if [ -f "$PID_FILE" ]; then
pid=$(cat "$PID_FILE")
rm -f "$PID_FILE"

# https://docs.fluentbit.io/manual/administration/configuring-fluent-bit/yaml/configuration-file#config_section
# The default grace time is set to 5 seconds, so use 6 seconds to have some margin.
timeout=6
while kill -0 "$pid" 2>/dev/null; do
[ $timeout -eq 0 ] && status=1 && break
timeout=$((timeout - 1))
sleep 1
done
fi

if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart | reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
3 changes: 3 additions & 0 deletions package/fluent-bit/fluent-bit.hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Locally computed
sha256 8ff5566389033669feabc9c69a5c6f417dad5c8b066454388e6a706507262acf fluent-bit-2.0.8.tar.gz
sha256 0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594 LICENSE
49 changes: 49 additions & 0 deletions package/fluent-bit/fluent-bit.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
################################################################################
#
# fluent-bit
#
################################################################################

FLUENT_BIT_VERSION = 2.0.8
FLUENT_BIT_SITE = $(call github,fluent,fluent-bit,v$(FLUENT_BIT_VERSION))
FLUENT_BIT_LICENSE = Apache-2.0
FLUENT_BIT_LICENSE_FILES = LICENSE
FLUENT_BIT_DEPENDENCIES = host-bison host-flex libyaml libopenssl

FLUENT_BIT_CONF_OPTS += \
-DFLB_DEBUG=No \
-DFLB_RELEASE=Yes \
-DFLB_EXAMPLES=No \
-DFLB_CHUNK_TRACE=No \
-DFLB_BACKTRACE=No

ifeq ($(BR2_PACKAGE_LUAJIT),y)
FLUENT_BIT_CONF_OPTS += -DFLB_LUAJIT=Yes
FLUENT_BIT_DEPENDENCIES += luajit
else
FLUENT_BIT_CONF_OPTS += -DFLB_LUAJIT=No
endif

# Force bundled miniz to be linked statically.
# https://github.com/fluent/fluent-bit/issues/6711
FLUENT_BIT_CONF_OPTS += \
-DBUILD_SHARED_LIBS=OFF

# Move the config files from /usr/etc/ to /etc/.
# https://github.com/fluent/fluent-bit/issues/6619
FLUENT_BIT_CONF_OPTS += \
-DCMAKE_INSTALL_SYSCONFDIR="/etc/"

# Undefining _FILE_OFFSET_BITS here because of a "bug" with glibc fts.h
# large file support.
# See https://bugzilla.redhat.com/show_bug.cgi?id=574992 for more information.
FLUENT_BIT_CONF_OPTS += \
-DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -U_FILE_OFFSET_BITS" \
-DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -U_FILE_OFFSET_BITS"

define FLUENT_BIT_INSTALL_INIT_SYSV
$(INSTALL) -D -m 0755 package/fluent-bit/S99fluent-bit \
$(TARGET_DIR)/etc/init.d/S99fluent-bit
endef

$(eval $(cmake-package))

0 comments on commit 6a0f7c3

Please sign in to comment.