Cleanup spec
Fix shutdown for redis-{server,sentinel} Backport fixes from Remi Collet repository Drop unused patch
This commit is contained in:
parent
071a048ef0
commit
bfae9dba22
@ -1,54 +0,0 @@
|
||||
Index: redis-2.8.11/redis.conf
|
||||
===================================================================
|
||||
--- redis-2.8.11.orig/redis.conf
|
||||
+++ redis-2.8.11/redis.conf
|
||||
@@ -34,11 +34,11 @@
|
||||
|
||||
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
||||
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
||||
-daemonize no
|
||||
+daemonize yes
|
||||
|
||||
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
|
||||
# default. You can specify a custom pid file location here.
|
||||
-pidfile /var/run/redis.pid
|
||||
+pidfile /var/run/redis/redis.pid
|
||||
|
||||
# Accept connections on the specified port, default is 6379.
|
||||
# If port 0 is specified Redis will not listen on a TCP socket.
|
||||
@@ -61,7 +61,7 @@ tcp-backlog 511
|
||||
# Examples:
|
||||
#
|
||||
# bind 192.168.1.100 10.0.0.1
|
||||
-# bind 127.0.0.1
|
||||
+bind 127.0.0.1
|
||||
|
||||
# Specify the path for the Unix socket that will be used to listen for
|
||||
# incoming connections. There is no default, so Redis will not listen
|
||||
@@ -87,7 +87,7 @@ timeout 0
|
||||
# On other kernels the period depends on the kernel configuration.
|
||||
#
|
||||
# A reasonable value for this option is 60 seconds.
|
||||
-tcp-keepalive 0
|
||||
+tcp-keepalive 60
|
||||
|
||||
# Specify the server verbosity level.
|
||||
# This can be one of:
|
||||
@@ -100,7 +100,7 @@ loglevel notice
|
||||
# Specify the log file name. Also the empty string can be used to force
|
||||
# Redis 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/redis/redis.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.
|
||||
@@ -184,7 +184,7 @@ dbfilename dump.rdb
|
||||
# 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/redis/
|
||||
|
||||
################################# REPLICATION #################################
|
||||
|
@ -4,8 +4,8 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/mkdir -p /var/lib/redis
|
||||
ExecStart=/usr/bin/redis-sentinel /etc/sentinel.conf
|
||||
ExecStop=/usr/bin/redis-cli shutdown
|
||||
ExecStart=/usr/bin/redis-sentinel /etc/redis-sentinel.conf
|
||||
ExecStop=/usr/bin/redis-shutdown sentinel
|
||||
User=redis
|
||||
Group=redis
|
||||
|
||||
|
@ -1,93 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# redis init file for starting up the redis daemon
|
||||
#
|
||||
# chkconfig: - 20 80
|
||||
# description: Starts and stops the redis daemon.
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
NAME="redis-server"
|
||||
EXEC="/usr/bin/$NAME"
|
||||
REDIS_CONFIG="/etc/redis.conf"
|
||||
RUNDIR="/var/run/redis"
|
||||
PIDFILE="$RUNDIR/redis.pid"
|
||||
|
||||
[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis
|
||||
|
||||
lockfile=/var/lock/subsys/redis
|
||||
|
||||
start() {
|
||||
[ -f $REDIS_CONFIG ] || exit 6
|
||||
[ -x $EXEC ] || exit 5
|
||||
echo -n $"Starting $NAME: "
|
||||
mkdir -p $RUNDIR
|
||||
touch $PIDFILE
|
||||
chown redis:redis $RUNDIR $PIDFILE
|
||||
chmod 750 $RUNDIR
|
||||
daemon --user ${REDIS_USER-redis} "$EXEC $REDIS_CONFIG"
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $NAME: "
|
||||
killproc -p $PIDFILE $NAME
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
false
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
status -p $PIDFILE $NAME
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
@ -1,13 +0,0 @@
|
||||
[Unit]
|
||||
Description=Redis persistent key-value database
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/mkdir -p /var/lib/redis
|
||||
ExecStart=/usr/bin/redis-server /etc/redis.conf
|
||||
ExecStop=/usr/bin/redis-cli shutdown
|
||||
User=redis
|
||||
Group=redis
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
28
redis-shutdown
Normal file
28
redis-shutdown
Normal file
@ -0,0 +1,28 @@
|
||||
#! /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="$2"
|
||||
if [ -z "$SERVICE_NAME" ]; then
|
||||
SERVICE_NAME=redis
|
||||
fi
|
||||
|
||||
# Get the proper config file based on service name
|
||||
CONFIG_FILE="/etc/$SERVICE_NAME.conf"
|
||||
|
||||
# Use awk to retrieve port from config file
|
||||
PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE`
|
||||
|
||||
# Just in case, use default port
|
||||
if [ "$SERVICE_NAME" = redis ]; then
|
||||
PORT=${PORT:-6279}
|
||||
else
|
||||
PORT=${PORT:-26739}
|
||||
fi
|
||||
|
||||
# shutdown the service properly
|
||||
$REDIS_CLI -p $PORT shutdown
|
@ -4,6 +4,7 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/redis-server /etc/redis.conf --daemonize no
|
||||
ExecStop=/usr/bin/redis-shutdown
|
||||
User=redis
|
||||
Group=redis
|
||||
|
||||
|
57
redis.spec
57
redis.spec
@ -1,5 +1,4 @@
|
||||
%global _hardened_build 1
|
||||
|
||||
%global with_perftools 0
|
||||
|
||||
# redis 2.8 sentinel is the first upstream version to work
|
||||
@ -15,17 +14,13 @@
|
||||
%global with_systemd 0
|
||||
%endif
|
||||
|
||||
# tcl 8.4 in EL5.
|
||||
%if 0%{?el5}
|
||||
%global with_tests 0
|
||||
%else
|
||||
%global with_tests 1
|
||||
%endif
|
||||
# Tests fail in mock, not in local build.
|
||||
%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
|
||||
|
||||
Name: redis
|
||||
Version: 2.8.14
|
||||
Release: 1%{?dist}
|
||||
Summary: A persistent caching system, key-value and data structures database
|
||||
Release: 2%{?dist}
|
||||
Summary: A persistent key-value database
|
||||
License: BSD
|
||||
URL: http://redis.io
|
||||
Source0: http://download.redis.io/releases/%{name}-%{version}.tar.gz
|
||||
@ -35,6 +30,7 @@ Source3: %{name}.service
|
||||
Source4: %{name}.tmpfiles
|
||||
Source5: %{name}-sentinel.init
|
||||
Source6: %{name}.init
|
||||
Source7: %{name}-shutdown
|
||||
# Update configuration for Fedora
|
||||
Patch0: redis-2.8.11-redis-conf.patch
|
||||
Patch1: redis-2.8.11-deps-library-fPIC-performance-tuning.patch
|
||||
@ -55,6 +51,8 @@ BuildRequires: systemd
|
||||
%if 0%{?with_tests}
|
||||
BuildRequires: tcl
|
||||
%endif
|
||||
# Required for redis-shutdown
|
||||
Requires: /bin/awk
|
||||
Requires: logrotate
|
||||
Requires(pre): shadow-utils
|
||||
%if 0%{?with_systemd}
|
||||
@ -165,6 +163,13 @@ install -pDm755 %{S:6} %{buildroot}%{_initrddir}/%{name}
|
||||
# Fix non-standard-executable-perm error.
|
||||
chmod 755 %{buildroot}%{_bindir}/%{name}-*
|
||||
|
||||
# create redis-sentinel command as described on
|
||||
# http://redis.io/topics/sentinel
|
||||
ln -s %{name}-server %{buildroot}%{_bindir}/%{name}-sentinel
|
||||
|
||||
# Install redis-shutdown
|
||||
install -pDm755 %{S:7} %{buildroot}%{_bindir}/%{name}-shutdown
|
||||
|
||||
%check
|
||||
%if 0%{?with_tests}
|
||||
make test ||:
|
||||
@ -174,7 +179,8 @@ make test-sentinel ||:
|
||||
%endif
|
||||
|
||||
%pre
|
||||
getent group %{name} &> /dev/null || groupadd -r %{name} &> /dev/null
|
||||
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 'Redis Database Server' %{name} &> /dev/null
|
||||
@ -182,54 +188,56 @@ exit 0
|
||||
|
||||
%post
|
||||
%if 0%{?with_systemd}
|
||||
%systemd_post %{name}.service
|
||||
%if 0%{?with_sentinel}
|
||||
%systemd_post %{name}-sentinel.service
|
||||
%endif
|
||||
%systemd_post %{name}.service
|
||||
%else
|
||||
chkconfig --add %{name}
|
||||
%if 0%{?with_sentinel}
|
||||
chkconfig --add %{name}-sentinel
|
||||
%endif
|
||||
chkconfig --add %{name}
|
||||
%endif
|
||||
|
||||
%preun
|
||||
%if 0%{?with_systemd}
|
||||
%systemd_preun %{name}.service
|
||||
%if 0%{?with_sentinel}
|
||||
%systemd_preun %{name}-sentinel.service
|
||||
%endif
|
||||
%systemd_preun %{name}.service
|
||||
%else
|
||||
if [ $1 -eq 0 ] ; then
|
||||
service %{name} stop &> /dev/null
|
||||
chkconfig --del %{name} &> /dev/null
|
||||
%if 0%{?with_sentinel}
|
||||
service %{name}-sentinel stop &> /dev/null
|
||||
chkconfig --del %{name}-sentinel &> /dev/null
|
||||
%endif
|
||||
service %{name} stop &> /dev/null
|
||||
chkconfig --del %{name} &> /dev/null
|
||||
%endif
|
||||
|
||||
%postun
|
||||
%if 0%{?with_systemd}
|
||||
%systemd_postun_with_restart %{name}.service
|
||||
%if 0%{?with_sentinel}
|
||||
%systemd_postun_with_restart %{name}-sentinel.service
|
||||
%endif
|
||||
%systemd_postun_with_restart %{name}.service
|
||||
%else
|
||||
if [ "$1" -ge "1" ] ; then
|
||||
service %{name} condrestart >/dev/null 2>&1 || :
|
||||
%if 0%{?with_sentinel}
|
||||
service %{name}-sentinel condrestart >/dev/null 2>&1 || :
|
||||
%endif
|
||||
service %{name} condrestart >/dev/null 2>&1 || :
|
||||
fi
|
||||
%endif
|
||||
|
||||
%files
|
||||
%doc 00-RELEASENOTES BUGS CONTRIBUTING COPYING MANIFESTO README
|
||||
%{!?_licensedir:%global license %%doc}
|
||||
%license COPYING
|
||||
%doc 00-RELEASENOTES BUGS CONTRIBUTING MANIFESTO README
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
|
||||
%config(noreplace) %{_sysconfdir}/%{name}.conf
|
||||
%attr(0644, redis, root) %config(noreplace) %{_sysconfdir}/%{name}.conf
|
||||
%if 0%{?with_sentinel}
|
||||
%config(noreplace) %{_sysconfdir}/%{name}-sentinel.conf
|
||||
%attr(0644, redis, root) %config(noreplace) %{_sysconfdir}/%{name}-sentinel.conf
|
||||
%endif
|
||||
%dir %attr(0750, redis, redis) %{_sharedstatedir}/%{name}
|
||||
%dir %attr(0750, redis, redis) %{_localstatedir}/log/%{name}
|
||||
@ -237,18 +245,23 @@ fi
|
||||
%{_bindir}/%{name}-*
|
||||
%if 0%{?with_systemd}
|
||||
%{_tmpfilesdir}/%{name}.conf
|
||||
%{_unitdir}/%{name}.service
|
||||
%if 0%{?with_sentinel}
|
||||
%{_unitdir}/%{name}-sentinel.service
|
||||
%endif
|
||||
%{_unitdir}/%{name}.service
|
||||
%else
|
||||
%{_initrddir}/%{name}
|
||||
%if 0%{?with_sentinel}
|
||||
%{_initrddir}/%{name}-sentinel
|
||||
%endif
|
||||
%{_initrddir}/%{name}
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Sep 11 2014 Haïkel Guémar <hguemar@fedoraproject.org> - 2.8.14-2
|
||||
- Cleanup spec
|
||||
- Fix shutdown for redis-{server,sentinel}
|
||||
- Backport fixes from Remi Collet repository (ie: sentinel working)
|
||||
|
||||
* Thu Sep 11 2014 Haïkel Guémar <hguemar@fedoraproject.org> - 2.8.14-1
|
||||
- Upstream 2.8.14 (RHBZ #1136287)
|
||||
- Bugfix for lua scripting users (server crash)
|
||||
|
Loading…
Reference in New Issue
Block a user