Skip to content

Commit

Permalink
Add Valkey
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Dec 20, 2024
1 parent f7d806c commit 6dce81e
Show file tree
Hide file tree
Showing 12 changed files with 719 additions and 0 deletions.
27 changes: 27 additions & 0 deletions specs/valkey/SOURCES/sentinel-72-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --color -urN valkey-7.2.7-orig/sentinel.conf valkey-7.2.7/sentinel.conf
--- valkey-7.2.7-orig/sentinel.conf 2024-10-02 23:11:08.000000000 +0300
+++ valkey-7.2.7/sentinel.conf 2024-12-20 15:59:42.000000000 +0300
@@ -1,5 +1,3 @@
-# Example sentinel.conf
-
# By default protected mode is disabled in sentinel mode. Sentinel is reachable
# from interfaces different than localhost. Make sure the sentinel instance is
# protected from the outside world via firewalling or other means.
@@ -17,7 +15,7 @@
# When running daemonized, Valkey Sentinel writes a pid file in
# /var/run/valkey-sentinel.pid by default. You can specify a custom pid file
# location here.
-pidfile /var/run/valkey-sentinel.pid
+pidfile /var/run/valkey/sentinel.pid

# Specify the server verbosity level.
# This can be one of:
@@ -31,7 +29,7 @@
# 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/valkey/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.
7 changes: 7 additions & 0 deletions specs/valkey/SOURCES/sentinel-limit-systemd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# If you need to change max open file limit
# for example, when you change maxclient in configuration
# you can change the LimitNOFILE value below
# see "man systemd.exec" for information

[Service]
LimitNOFILE=10240
9 changes: 9 additions & 0 deletions specs/valkey/SOURCES/sentinel.logrotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/var/log/redis/sentinel.log {
weekly
rotate 10
copytruncate
delaycompress
compress
notifempty
missingok
}
14 changes: 14 additions & 0 deletions specs/valkey/SOURCES/sentinel.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Valkey Sentinel
Documentation=https://valkey.io/docs
After=syslog.target network.target

[Service]
ExecStart=/usr/bin/valkey-sentinel /etc/sentinel.conf --daemonize no
KillSignal=SIGTERM
User=valkey
Group=valkey
PIDFile=/var/run/valkey/sentinel.pid

[Install]
WantedBy=multi-user.target
57 changes: 57 additions & 0 deletions specs/valkey/SOURCES/valkey-72-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --color -urN valkey-7.2.7-orig/valkey.conf valkey-7.2.7/valkey.conf
--- valkey-7.2.7-orig/valkey.conf 2024-10-02 23:11:08.000000000 +0300
+++ valkey-7.2.7/valkey.conf 2024-12-20 15:56:04.000000000 +0300
@@ -84,7 +84,7 @@
# You will also need to set a password unless you explicitly disable protected
# mode.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-bind 127.0.0.1 -::1
+# bind 127.0.0.1 -::1

# By default, outgoing connections (from replica to master, from Sentinel to
# instances, cluster bus, etc.) are not bound to a specific local address. In
@@ -335,7 +335,7 @@
#
# Note that on modern Linux systems "/run/valkey.pid" is more conforming
# and should be used instead.
-pidfile /var/run/valkey_6379.pid
+pidfile /var/run/valkey/valkey.pid

# Specify the server verbosity level.
# This can be one of:
@@ -349,7 +349,7 @@
# Specify the log file name. Also the empty string can be used to force
# the server 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/valkey/valkey.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.
@@ -374,7 +374,7 @@
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
-databases 16
+databases 96

# By default the server shows an ASCII art logo only when started to log to the
# standard output and if the standard output is a TTY and syslog logging is
@@ -433,7 +433,7 @@
#
# You can set these explicitly by uncommenting the following line.
#
-# save 3600 1 300 100 60 10000
+save 3600 1 300 100 60 10000

# By default the server will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
@@ -504,7 +504,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/valkey/

################################# REPLICATION #################################

7 changes: 7 additions & 0 deletions specs/valkey/SOURCES/valkey-limit-systemd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# If you need to change max open file limit
# for example, when you change maxclient in configuration
# you can change the LimitNOFILE value below
# see "man systemd.exec" for information

[Service]
LimitNOFILE=10240
9 changes: 9 additions & 0 deletions specs/valkey/SOURCES/valkey.logrotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/var/log/valkey/valkey.log {
weekly
rotate 10
copytruncate
delaycompress
compress
notifempty
missingok
}
17 changes: 17 additions & 0 deletions specs/valkey/SOURCES/valkey.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Valkey
Documentation=https://valkey.io/docs
After=syslog.target network.target

[Service]
Type=notify
ExecStart=/usr/bin/valkey-server /etc/valkey.conf --supervised systemd
KillSignal=SIGTERM
User=valkey
Group=valkey
PIDFile=/var/run/valkey/valkey.pid
TimeoutStartSec=15
TimeoutStopSec=90

[Install]
WantedBy=multi-user.target
195 changes: 195 additions & 0 deletions specs/valkey/valkey.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
################################################################################

%global crc_check pushd ../SOURCES ; sha512sum -c %{SOURCE100} ; popd

################################################################################

%{!?_without_check: %define _with_check 1}

################################################################################

%define major_ver 7
%define minor_ver 2

################################################################################

Summary: A persistent key-value database
Name: valkey
Version: 7.2.7
Release: 0%{?dist}
License: BSD
Group: Applications/Databases
URL: https://valkey.io

Source0: https://github.com/valkey-io/%{name}/archive/%{version}.tar.gz
Source1: %{name}.logrotate
Source2: sentinel.logrotate
Source3: %{name}.service
Source4: sentinel.service
Source5: %{name}-limit-systemd
Source6: sentinel-limit-systemd

Source100: checksum.sha512

Patch0: valkey-%{major_ver}%{minor_ver}-config.patch
Patch1: sentinel-%{major_ver}%{minor_ver}-config.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: make gcc tcl systemd-devel

Requires: %{name}-cli >= %{version}
Requires: logrotate

Requires(pre): shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

Conflicts: redis valkey72

Provides: %{name} = %{version}-%{release}
Provides: %{name}-server = %{version}-%{release}
Provides: %{name}-sentinel = %{version}-%{release}

################################################################################

%description
Valkey is a high-performance data structure server that primarily serves
key/value workloads. It supports a wide range of native structures and an
extensible plugin system for adding new data structures and access patterns.

################################################################################

%package cli

Summary: Client for working with Valkey from console
Group: Applications/Databases

%description cli
Client for working with Valkey from console

################################################################################

%package devel

Summary: Development header for Valkey module development
Group: Development/Libraries

Provides: %{name}-static = %{version}-%{release}

%description devel
Header file required for building loadable Valkey modules.

################################################################################

%prep
%crc_check
%autosetup -p1 -n %{name}-%{version}

%build
export BUILD_WITH_SYSTEMD=yes

%{__make} %{?_smp_mflags} MALLOC=jemalloc

%install
rm -rf %{buildroot}

%{__make} install PREFIX=%{buildroot}%{_prefix}

install -dm 755 %{buildroot}%{_sysconfdir}
install -dm 755 %{buildroot}%{_sysconfdir}/logrotate.d
install -dm 755 %{buildroot}%{_sysconfdir}/sysconfig

install -pm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -pm 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/sentinel

install -pm 640 %{name}.conf %{buildroot}%{_sysconfdir}/
install -pm 640 sentinel.conf %{buildroot}%{_sysconfdir}/

install -dm 755 %{buildroot}%{_localstatedir}/lib/%{name}
install -dm 755 %{buildroot}%{_localstatedir}/log/%{name}
install -dm 755 %{buildroot}%{_localstatedir}/run/%{name}

install -dm 755 %{buildroot}%{_unitdir}
install -dm 755 %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d
install -dm 755 %{buildroot}%{_sysconfdir}/systemd/system/sentinel.service.d
install -pm 644 %{SOURCE3} %{buildroot}%{_unitdir}/
install -pm 644 %{SOURCE4} %{buildroot}%{_unitdir}/
install -pm 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf
install -pm 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/systemd/system/sentinel.service.d/limit.conf

install -dm 755 %{buildroot}%{_includedir}
install -pm 644 src/redismodule.h %{buildroot}%{_includedir}/redismodule.h

chmod 755 %{buildroot}%{_bindir}/%{name}-*

rm -f %{buildroot}%{_bindir}/%{name}-sentinel

install -dm 755 %{buildroot}%{_sbindir}

ln -sf %{_bindir}/%{name}-server %{buildroot}%{_bindir}/%{name}-sentinel
ln -sf %{_bindir}/%{name}-server %{buildroot}%{_sbindir}/%{name}-server

%check
%if %{?_with_check:1}%{?_without_check:0}
%{__make} %{?_smp_mflags} test
%{__make} %{?_smp_mflags} test-sentinel
%endif

%pre
getent group %{name} &> /dev/null || groupadd -r %{name} &> /dev/null
getent passwd %{name} &> /dev/null || \
useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \
-c 'Valkey Server' %{name} &> /dev/null

%post
if [[ $1 -eq 1 ]] ; then
systemctl enable %{name}.service &>/dev/null || :
fi

%preun
if [[ $1 -eq 0 ]] ; then
systemctl --no-reload disable %{name}.service &>/dev/null || :
systemctl --no-reload disable sentinel.service &>/dev/null || :
systemctl stop %{name}.service &>/dev/null || :
systemctl stop sentinel.service &>/dev/null || :
fi

%postun
systemctl daemon-reload &>/dev/null || :

################################################################################

%files
%defattr(-,root,root,-)
%doc 00-RELEASENOTES BUGS COPYING README.md
%attr(-,%{name},%{name}) %config(noreplace) %{_sysconfdir}/*.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/sentinel
%dir %attr(0755,%{name},root) %{_localstatedir}/lib/%{name}
%dir %attr(0755,%{name},root) %{_localstatedir}/log/%{name}
%dir %attr(0755,%{name},root) %{_localstatedir}/run/%{name}
%{_unitdir}/%{name}.service
%{_unitdir}/sentinel.service
%{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf
%{_sysconfdir}/systemd/system/sentinel.service.d/limit.conf
%{_bindir}/%{name}-*
%{_bindir}/redis-*
%{_sbindir}/%{name}-server

%files cli
%defattr(-,root,root,-)
%doc 00-RELEASENOTES BUGS COPYING README.md
%{_bindir}/%{name}-cli

%files devel
%doc COPYING
%defattr(-,root,root,-)
%{_includedir}/redismodule.h

################################################################################

%changelog
* Fri Dec 20 2024 Anton Novojilov <andy@essentialkaos.com> - 7.2.7-0
- https://github.com/valkey-io/valkey/blob/7.2.7/00-RELEASENOTES
Loading

0 comments on commit 6dce81e

Please sign in to comment.