drop redis-shutdown helper and rely on systemd #2181181

This commit is contained in:
Remi Collet 2023-03-28 08:49:05 +02:00
parent 3cd0123a1f
commit 9e746bc4fc
4 changed files with 4 additions and 50 deletions

View File

@ -6,7 +6,6 @@ Wants=network-online.target
[Service] [Service]
ExecStart=/usr/bin/redis-sentinel /etc/redis/sentinel.conf --daemonize no --supervised systemd ExecStart=/usr/bin/redis-sentinel /etc/redis/sentinel.conf --daemonize no --supervised systemd
ExecStop=/usr/libexec/redis-shutdown sentinel
Type=notify Type=notify
User=redis User=redis
Group=redis Group=redis

View File

@ -1,40 +0,0 @@
#!/bin/bash
#
# Wrapper to close properly redis and sentinel
test x"$REDIS_DEBUG" != x && set -x
REDIS_CLI=/usr/bin/redis-cli
# Retrieve service name
SERVICE_NAME="$1"
if [ -z "$SERVICE_NAME" ]; then
SERVICE_NAME=redis
fi
# Get the proper config file based on service name
CONFIG_FILE="/etc/redis/$SERVICE_NAME.conf"
# Use awk to retrieve host, port from config file
HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE | tail -n1`
PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE | tail -n1`
PASS=`awk '/^[[:blank:]]*requirepass/ { print $2 }' $CONFIG_FILE | tail -n1`
SOCK=`awk '/^[[:blank:]]*unixsocket\s/ { print $2 }' $CONFIG_FILE | tail -n1`
# Just in case, use default host, port
HOST=${HOST:-127.0.0.1}
if [ "$SERVICE_NAME" = redis ]; then
PORT=${PORT:-6379}
else
PORT=${PORT:-26739}
fi
# Setup additional parameters
# e.g password-protected redis instances
[ -z "$PASS" ] || ADDITIONAL_PARAMS="-a $PASS"
# shutdown the service properly
if [ -e "$SOCK" ] ; then
$REDIS_CLI -s $SOCK $ADDITIONAL_PARAMS shutdown
else
$REDIS_CLI -h $HOST -p $PORT $ADDITIONAL_PARAMS shutdown
fi

View File

@ -6,7 +6,6 @@ Wants=network-online.target
[Service] [Service]
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd
ExecStop=/usr/libexec/redis-shutdown
Type=notify Type=notify
User=redis User=redis
Group=redis Group=redis

View File

@ -26,7 +26,7 @@
Name: redis Name: redis
Version: %{upstream_ver}%{?upstream_pre:~%{upstream_pre}} Version: %{upstream_ver}%{?upstream_pre:~%{upstream_pre}}
Release: 1%{?dist} Release: 2%{?dist}
Summary: A persistent key-value database Summary: A persistent key-value database
# redis, hiredis: BSD-3-Clause # redis, hiredis: BSD-3-Clause
# hdrhistogram, jemalloc, lzf, linenoise: BSD-2-Clause # hdrhistogram, jemalloc, lzf, linenoise: BSD-2-Clause
@ -37,7 +37,6 @@ URL: https://redis.io
Source0: https://download.redis.io/releases/%{name}-%{upstream_ver}%{?upstream_pre:-%{upstream_pre}}.tar.gz Source0: https://download.redis.io/releases/%{name}-%{upstream_ver}%{?upstream_pre:-%{upstream_pre}}.tar.gz
Source1: %{name}.logrotate Source1: %{name}.logrotate
Source2: %{name}-sentinel.service Source2: %{name}-sentinel.service
Source6: %{name}-shutdown
Source3: %{name}.service Source3: %{name}.service
Source7: %{name}-limit-systemd Source7: %{name}-limit-systemd
Source9: macros.%{name} Source9: macros.%{name}
@ -64,8 +63,6 @@ BuildRequires: systemd-rpm-macros
BuildRequires: openssl-devel BuildRequires: openssl-devel
# redis-trib functionality migrated to redis-cli # redis-trib functionality migrated to redis-cli
Obsoletes: redis-trib < 5 Obsoletes: redis-trib < 5
# Required for redis-shutdown
Requires: /bin/awk
Requires: logrotate Requires: logrotate
Requires(pre): shadow-utils Requires(pre): shadow-utils
Requires(post): systemd Requires(post): systemd
@ -194,9 +191,6 @@ install -p -D -m 644 %{S:7} %{buildroot}%{_sysconfdir}/systemd/system/%{name}-se
# Fix non-standard-executable-perm error. # Fix non-standard-executable-perm error.
chmod 755 %{buildroot}%{_bindir}/%{name}-* chmod 755 %{buildroot}%{_bindir}/%{name}-*
# Install redis-shutdown
install -pDm755 %{S:6} %{buildroot}%{_libexecdir}/%{name}-shutdown
# Install redis module header # Install redis module header
install -pDm644 src/%{name}module.h %{buildroot}%{_includedir}/%{name}module.h install -pDm644 src/%{name}module.h %{buildroot}%{_includedir}/%{name}module.h
@ -289,7 +283,6 @@ fi
%exclude %{_includedir} %exclude %{_includedir}
%exclude %{_docdir}/%{name}/* %exclude %{_docdir}/%{name}/*
%{_bindir}/%{name}-* %{_bindir}/%{name}-*
%{_libexecdir}/%{name}-*
%{_mandir}/man1/%{name}* %{_mandir}/man1/%{name}*
%{_mandir}/man5/%{name}* %{_mandir}/man5/%{name}*
%{_unitdir}/%{name}.service %{_unitdir}/%{name}.service
@ -314,6 +307,9 @@ fi
%changelog %changelog
* Tue Mar 28 2023 Remi Collet <remi@remirepo.net> - 7.2~rc1-2
- drop redis-shutdown helper and rely on systemd #2181181
* Thu Mar 23 2023 Remi Collet <remi@remirepo.net> - 7.2~rc1-1 * Thu Mar 23 2023 Remi Collet <remi@remirepo.net> - 7.2~rc1-1
- Upstream 7.2-rc1 release candidate. - Upstream 7.2-rc1 release candidate.