testing/keydb: new aport

This commit is contained in:
Jakub Jirutka 2024-05-25 19:53:57 +02:00
parent 476fad854d
commit 475c985f35
10 changed files with 413 additions and 0 deletions

113
testing/keydb/APKBUILD Normal file
View File

@ -0,0 +1,113 @@
# Contributor: Milan P. Stanić <mps@arvanta.net>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=keydb
pkgver=6.3.4
pkgrel=0
pkgdesc="High performance multithreaded fork of Redis"
url="https://keydb.dev"
# armhf,armv7,x86: not supported
# ppc64le: fails to build (undefined reference to 'getcontext')
arch="all !armhf !armv7 !ppc64le !x86"
# hiredis: BSD-3-Clause
# hdrhistogram, jemalloc, linenoise: BSD-2-Clause
# lua: MIT
license="BSD-3-Clause AND BSD-2-Clause AND MIT"
makedepends="
libunwind-dev
linux-headers
openssl-dev
util-linux-dev
zlib-dev
"
checkdepends="
procps
tcl
"
pkgusers="keydb"
pkggroups="keydb"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="
$pkgname-benchmark
$pkgname-cli
$pkgname-openrc
"
source="$pkgname-$pkgver.tar.gz::https://github.com/JohnSully/KeyDB/archive/v$pkgver.tar.gz
keydb.conf.patch
sentinel.conf.patch
deps-makefile.patch
$pkgname.initd
$pkgname.confd
$pkgname-sentinel.initd
$pkgname-sentinel.confd
"
builddir="$srcdir/KeyDB-$pkgver"
options="!check" # tests fail randomly
# USE_JEMALLOC uses bundled jemalloc
_make_opts="\
BUILD_TLS=yes \
NO_MOTD=yes \
PREFIX=/usr \
USE_JEMALLOC=yes \
USE_SYSTEMD=no \
"
build() {
export CFLAGS="$CFLAGS -O2"
make $_make_opts all
}
check() {
make test $_make_opts
}
package() {
make install $_make_opts INSTALL_BIN="$pkgdir/usr/bin"
cd "$pkgdir"
# NOTE: /etc/keydb and /etc/keydb/sentinel.conf must be writable for keydb,
# otherwise Sentinel fails to start.
install -d -m 750 -o keydb -g keydb \
etc/keydb \
etc/keydb/keydb.d \
var/lib/keydb \
var/lib/keydb/sentinel
install -D -m 640 -o root -g keydb "$builddir"/keydb.conf etc/keydb/keydb.conf
install -D -m 640 -o keydb -g keydb "$builddir"/sentinel.conf etc/keydb/sentinel.conf
install -D -m 755 "$srcdir"/keydb.initd etc/init.d/keydb
install -D -m 755 "$srcdir"/keydb-sentinel.initd etc/init.d/keydb-sentinel
install -D -m 644 "$srcdir"/keydb.confd etc/conf.d/keydb
install -D -m 644 "$srcdir"/keydb-sentinel.confd etc/conf.d/keydb-sentinel
install -d -m 750 -o keydb -g keydb \
var/lib/keydb \
var/lib/keydb/sentinel
}
benchmark() {
pkgdesc="KeyDB benchmarking tool"
amove usr/bin/keydb-benchmark
}
cli() {
pkgdesc="KeyDB CLI client"
amove usr/bin/keydb-cli
}
sha512sums="
6ac5060dc60df878668830336821cac740690be5525bc8c4a31a522c629b73df2da49f6d53fe8ebfec171efef258c9253d91243fe57a470aaabeddea2ac5247b keydb-6.3.4.tar.gz
add4b21b9ecc8c18046462caaac58cc26c837136573c912b0904e107ce2ae684a409e575a924b33310955b9ac76b42330b494efcbe94e02ede5136244e7b165a keydb.conf.patch
50ce23119c1ddb6e63999740299711bd3a7a8500ce6b75f7850012b2edae13051dba43e7628788255f2d16dfe913da92222cae9908a3d8f7b619c2ee70e2a44f sentinel.conf.patch
be06084939bb8d26f638f09b21c1edcc06d738b5cd0647ab2bc3f4b01f5a61c63486e1ac913de30278a7d9474cf2fc965903b48305551aa699ec43834acaf56a deps-makefile.patch
b70d0bc0207c606be8ef3d099769075c8925c989fe2ca121e4368407fb1662010e18a745c1602679a376dd97eaf2e1ee01c1d41e7ab02e2019172b6b4adb2e6a keydb.initd
91dfd649c326c3bf0be24094e662f7347d84028527ddc6e6819564ad862deadd7b246e0f518b38a3c4e768c1ef1c54471ddb8f56c8c54177c61e15dff0d7ba60 keydb.confd
8c7825e2c6a579cca3d4197be4811bfb37d516cd5d31c667ffc589245306f4a8e8ec86eeab170d3e90d2f069c691dd779236c97848794a483206df09134e5d65 keydb-sentinel.initd
d86345a469b5ae731b7dc80577b1f71ac97928cba162f7376a9088ada52abe99c9e042ff5b827c40cab0267b95967e5ffd8fb9a23c0d55822aba22e0ab4f2086 keydb-sentinel.confd
"

View File

@ -0,0 +1,11 @@
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -95,7 +95,7 @@
jemalloc: .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
- cd jemalloc && ./configure --with-version=5.2.1-0-g0 --with-lg-quantum=3 --disable-cxx CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
+ cd jemalloc && ./configure --with-version=5.2.1-0-g0 --with-lg-quantum=3 --disable-cxx $(JEMALLOC_OPTS) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a
.PHONY: jemalloc

View File

@ -0,0 +1,10 @@
# Configuration for /etc/init.d/keydb-sentinel
# KeyDB Sentinel configuration file.
#cfgfile="/etc/keydb/sentinel.conf"
# User (and group) to run keydb as.
#command_user="keydb:keydb"
# Uncomment to run with process supervisor.
# supervisor="supervise-daemon"

View File

@ -0,0 +1,38 @@
#!/sbin/openrc-run
name="KeyDB Sentinel"
: ${cfgfile:="/etc/keydb/sentinel.conf"}
: ${command_user:="keydb:keydb"}
command="/usr/bin/keydb-sentinel"
command_args="$cfgfile --daemonize no $command_args"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"
required_files="$cfgfile"
depend() {
use net localmount logger
after keepalived firewall keydb
provide redis-sentinel
}
start_pre() {
# Sets start-start-daemon's --chdir.
directory="$(config_get 'dir' '/var/lib/keydb')" || return 1
local logfile="$(config_get 'logfile')"
if [ "$logfile" ]; then
checkpath -f -o "$command_user" "$logfile" || return 1
fi
}
config_get() {
local key="$1"
local default="${2:-}"
local value="$(awk "\$1 == \"$key\" { print \$2 }" "$cfgfile")"
printf '%s\n' "${value:-$default}"
}

View File

@ -0,0 +1,106 @@
We force "daemonize no" in init script, so daemonize and pidfile does not
have any effect in keydb.conf. It's init/rc system's job to daemonize
programs and handle pidfiles, if it needs it!
Applications often communicate with Redis via unix socket, so it's
convenient to have it enabled by default. It must be in a subdirectory that
is automatically created by the init script because keydb user has no
permission to create files in /run.
--- a/keydb.conf
+++ b/keydb.conf
@@ -123,8 +123,8 @@
# incoming connections. There is no default, so KeyDB will not listen
# on a unix socket when not specified.
#
-# unixsocket /tmp/keydb.sock
-# unixsocketperm 700
+unixsocket /run/keydb/keydb.sock
+unixsocketperm 770
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
@@ -279,10 +279,6 @@
################################# GENERAL #####################################
-# By default KeyDB does not run as a daemon. Use 'yes' if you need it.
-# Note that KeyDB will write a pid file in /var/run/keydb.pid when daemonized.
-daemonize no
-
# If you run KeyDB from upstart or systemd, KeyDB can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
@@ -295,17 +291,6 @@
# They do not enable continuous pings back to your supervisor.
supervised no
-# If a pid file is specified, KeyDB writes it where specified at startup
-# and removes it at exit.
-#
-# When the server runs non daemonized, no pid file is created if none is
-# specified in the configuration. When the server is daemonized, the pid file
-# is used even if not specified, defaulting to "/var/run/keydb.pid".
-#
-# Creating a pid file is best effort: if KeyDB is not able to create it
-# nothing bad happens, the server will start and run normally.
-pidfile /var/run/keydb_6379.pid
-
# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
@@ -317,14 +302,14 @@
# Specify the log file name. Also the empty string can be used to force
# KeyDB to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
-logfile ""
+# logfile "/var/log/keydb.log"
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
-# syslog-enabled no
+syslog-enabled yes
# Specify the syslog identity.
-# syslog-ident keydb
+syslog-ident keydb
# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0
@@ -350,16 +335,13 @@
#
# However it is possible to force the pre-4.0 behavior and always show a
# ASCII art logo in startup logs by setting the following option to yes.
-always-show-logo yes
+# always-show-logo yes
# By default, KeyDB modifies the process title (as seen in 'top' and 'ps') to
# provide some runtime information. It is possible to disable this and leave
# the process name as executed by setting the following to no.
set-proc-title yes
-# Retrieving "message of today" using CURL requests.
-#enable-motd yes
-
# When changing the process title, KeyDB uses the following template to construct
# the modified title.
#
@@ -470,7 +452,7 @@
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
-dir ./
+dir /var/lib/keydb
################################# REPLICATION #################################
@@ -2105,4 +2087,7 @@
# this is only exposed via the info command for clients to use, but in the future we
# we may also use this when making decisions for replication.
#
-# availability-zone "us-east-1a"
\ No newline at end of file
+# availability-zone "us-east-1a"
+
+# Include configuration fragments.
+include /etc/keydb/keydb.d/*.conf

10
testing/keydb/keydb.confd Normal file
View File

@ -0,0 +1,10 @@
# Configuration for /etc/init.d/keydb
# KeyDB configuration file.
#cfgfile="/etc/keydb/keydb.conf"
# User (and group) to run keydb as.
#command_user="keydb:keydb"
# Uncomment to run with process supervisor.
# supervisor="supervise-daemon"

46
testing/keydb/keydb.initd Normal file
View File

@ -0,0 +1,46 @@
#!/sbin/openrc-run
name="KeyDB server"
description="High performance multithreaded fork of Redis"
: ${cfgfile:="/etc/keydb/keydb.conf"}
: ${command_user:="keydb:keydb"}
command="/usr/bin/keydb-server"
command_args="$cfgfile --daemonize no $command_args"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"
required_files="$cfgfile"
depend() {
use net localmount logger
after keepalived firewall
provide redis
}
start_pre() {
# Sets start-start-daemon's --chdir.
directory="$(config_get 'dir' '/var/lib/keydb')"
checkpath -d -o "$command_user" "$directory" || return 1
local logfile="$(config_get 'logfile')"
if [ "$logfile" ]; then
checkpath -f -o "$command_user" "$logfile" || return 1
fi
local unixsocket="$(config_get 'unixsocket')"
if [ "$unixsocket" ] && ! [ -e "${unixsocket%/*}" ]; then
checkpath -d -o "$command_user" "${unixsocket%/*}" || return 1
fi
return 0
}
config_get() {
local key="$1"
local default="${2:-}"
local value="$(awk "\$1 == \"$key\" { print \$2 }" "$cfgfile")"
printf '%s\n' "${value:-$default}"
}

View File

@ -0,0 +1,11 @@
#!/bin/sh
# Create directory for the socket if OpenRC is not present (e.g. in container).
# It's conditioned using post-install script specifically to avoid easily
# overlookable mistakes in the init script (service working until the
# first restart).
if ! [ -e /sbin/openrc ]; then
install -d -m 755 -o keydb -g keydb /run/keydb
fi
exit 0

View File

@ -0,0 +1,6 @@
#!/bin/sh
addgroup -S keydb 2>/dev/null
adduser -S -D -H -h /var/lib/keydb -s /sbin/nologin -G keydb -g keydb keydb 2>/dev/null
exit 0

View File

@ -0,0 +1,62 @@
--- a/sentinel.conf
+++ b/sentinel.conf
@@ -20,21 +20,21 @@
# The port that this sentinel instance will run on
port 26379
-# By default KeyDB Sentinel does not run as a daemon. Use 'yes' if you need it.
-# Note that KeyDB will write a pid file in /var/run/keydb-sentinel.pid when
-# daemonized.
-daemonize no
-
-# When running daemonized, KeyDB Sentinel writes a pid file in
-# /var/run/keydb-sentinel.pid by default. You can specify a custom pid file
-# location here.
-pidfile /var/run/keydb-sentinel.pid
-
# Specify the log file name. Also the empty string can be used to force
# Sentinel to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
-logfile ""
+# logfile "/var/log/keydb/sentinel.log"
+# To enable logging to the system logger, just set 'syslog-enabled' to yes,
+# and optionally update the other syslog parameters to suit your needs.
+syslog-enabled yes
+
+# Specify the syslog identity.
+syslog-ident sentinel
+
+# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
+# syslog-facility local0
+
# sentinel announce-ip <ip>
# sentinel announce-port <port>
#
@@ -62,7 +62,7 @@
# For KeyDB Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to don't interfere with administrative tasks such as
# unmounting filesystems.
-dir /tmp
+dir /var/lib/keydb/sentinel
# sentinel monitor <master-name> <ip> <keydb-port> <quorum>
#
@@ -261,7 +261,7 @@
#
# Example:
#
-# sentinel notification-script mymaster /var/keydb/notify.sh
+# sentinel notification-script mymaster /etc/keydb/notify.sh
# CLIENTS RECONFIGURATION SCRIPT
#
@@ -286,7 +286,7 @@
#
# Example:
#
-# sentinel client-reconfig-script mymaster /var/keydb/reconfig.sh
+# sentinel client-reconfig-script mymaster /etc/keydb/reconfig.sh
# SECURITY
#