- Added logging to /var/log/redis/redis.log.

- Added log rotation.

OBS-URL: https://build.opensuse.org/package/show/server:database/redis?expand=0&rev=16
This commit is contained in:
Andreas Schneider 2011-01-18 21:10:38 +00:00 committed by Git OBS Bridge
parent 1bb7c7e532
commit aa12e8e31f
5 changed files with 72 additions and 21 deletions

View File

@ -20,7 +20,7 @@ Index: redis.conf
# Close the connection after a client is idle for N seconds (0 to disable) # Close the connection after a client is idle for N seconds (0 to disable)
timeout 300 timeout 300
@@ -24,7 +24,7 @@ timeout 300 @@ -24,12 +24,12 @@ timeout 300
# debug (a lot of information, useful for development/testing) # debug (a lot of information, useful for development/testing)
# notice (moderately verbose, what you want in production probably) # notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged) # warning (only very important / critical messages are logged)
@ -29,6 +29,12 @@ Index: redis.conf
# Specify the log file name. Also 'stdout' can be used to force # Specify the log file name. Also 'stdout' can be used to force
# the demon to log on the standard output. Note that if you use standard # the demon 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 stdout
+logfile /var/log/redis/redis.log
# 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
@@ -64,7 +64,7 @@ dbfilename dump.rdb @@ -64,7 +64,7 @@ dbfilename dump.rdb
# For default save/load DB in/from the working directory # For default save/load DB in/from the working directory

View File

@ -2,7 +2,7 @@ Index: utils/redis_init_script
=================================================================== ===================================================================
--- utils/redis_init_script.orig --- utils/redis_init_script.orig
+++ utils/redis_init_script +++ utils/redis_init_script
@@ -1,36 +1,69 @@ @@ -1,36 +1,75 @@
#!/bin/sh #!/bin/sh
+# +#
+# /etc/init.d/redis +# /etc/init.d/redis
@ -27,6 +27,7 @@ Index: utils/redis_init_script
-PIDFILE=/var/run/redis_${REDISPORT}.pid -PIDFILE=/var/run/redis_${REDISPORT}.pid
-CONF="/etc/redis/${REDISPORT}.conf" -CONF="/etc/redis/${REDISPORT}.conf"
+LOGFILE=/var/log/redis.log
+PIDFILE=/var/run/redis.pid +PIDFILE=/var/run/redis.pid
+CONF=/etc/redis.conf +CONF=/etc/redis.conf
@ -38,6 +39,11 @@ Index: utils/redis_init_script
- else - else
- echo -n "Starting Redis server...\n" - echo -n "Starting Redis server...\n"
- $EXEC $CONF - $EXEC $CONF
+ # Create a logfile the server can write into.
+ if [ ! -r $LOGFILE ]; then
+ touch $LOGFILE
+ chown redis:redis $LOGFILE
+ fi
+ # Create a pidfile the server can write into. + # Create a pidfile the server can write into.
+ if [ ! -r $PIDFILE ]; then + if [ ! -r $PIDFILE ]; then
+ touch $PIDFILE + touch $PIDFILE

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jan 18 21:08:35 UTC 2011 - asn@cryptomilk.org
- Added logging to /var/log/redis/redis.log.
- Added log rotation.
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jan 10 16:29:31 CET 2011 - asn@cryptomilk.org Mon Jan 10 16:29:31 CET 2011 - asn@cryptomilk.org

9
redis.logrotate Normal file
View File

@ -0,0 +1,9 @@
/var/log/redis/*.log {
weekly
rotate 10
copytruncate
delaycompress
compress
notifempty
missingok
}

View File

@ -14,21 +14,28 @@
# norootforbuild # norootforbuild
%define _home_dir %{_var}/run/%{name}
%define _data_dir %{_var}/lib/%{name}
Name: redis Name: redis
Version: 1.2.6 Version: 1.2.6
Release: 1 Release: 1
Url: http://code.google.com/p/redis/ #
License: BSD License License: BSD License
Group: Productivity/Databases/Servers Group: Productivity/Databases/Servers
Summary: Persistent key-value database with built-in net interface Summary: Persistent key-value database
Url: http://code.google.com/p/redis/
#
Source: http://redis.googlecode.com/files/%{name}-%{version}.tar.bz2 Source: http://redis.googlecode.com/files/%{name}-%{version}.tar.bz2
Source1: %{name}.logrotate
#
Patch0: %{name}-initscript.patch Patch0: %{name}-initscript.patch
Patch1: %{name}-conf.patch Patch1: %{name}-conf.patch
#
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# for init script # for init script
Requires: netcat Requires: netcat
BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: logrotate
%define pkg_homedir %{_var}/run/%{name}
%define pkg_datadir %{_var}/lib/%{name}
%description %description
Redis is an advanced key-value store. It is similar to memcached but the dataset Redis is an advanced key-value store. It is similar to memcached but the dataset
@ -39,12 +46,12 @@ side union, intersection, difference between sets, and so forth. Redis supports
different kind of sorting abilities. different kind of sorting abilities.
%package doc %package doc
Summary: HTML documentation for Redis Summary: HTML documentation for redis
Group: Productivity/Databases/Servers Group: Productivity/Databases/Servers
Requires: redis = %{version} Requires: redis = %{version}
%description doc %description doc
HTML documentation for Redis HTML documentation for redis database.
%prep %prep
%setup -q %setup -q
@ -56,20 +63,37 @@ mv doc html
make PROF="%{optflags}" %{?jobs:-j%jobs} make PROF="%{optflags}" %{?jobs:-j%jobs}
%install %install
install -D -m 0755 redis-benchmark $RPM_BUILD_ROOT%{_bindir}/redis-benchmark %{__install} -Dd -m 0755 \
install -D -m 0755 redis-cli $RPM_BUILD_ROOT%{_bindir}/redis-cli %{buildroot}%{_sysconfdir}/init.d \
install -D -m 0755 redis-server $RPM_BUILD_ROOT%{_sbindir}/redis-server %{buildroot}%{_sysconfdir}/logrotate.d \
install -D -m 0755 utils/redis_init_script $RPM_BUILD_ROOT%{_sysconfdir}/init.d/redis %{buildroot}%{_bindir} \
ln -s %{_sysconfdir}/init.d/redis $RPM_BUILD_ROOT%{_sbindir}/rcredis %{buildroot}%{_libdir} \
install -D -m 0644 redis.conf $RPM_BUILD_ROOT%{_sysconfdir}/redis.conf %{buildroot}%{_sbindir} \
install -d $RPM_BUILD_ROOT%{pkg_homedir} $RPM_BUILD_ROOT%{pkg_datadir} %{buildroot}%{_data_dir}
%{__install} -m 0755 redis-benchmark %{buildroot}%{_bindir}/redis-benchmark
%{__install} -m 0755 redis-cli %{buildroot}%{_bindir}/redis-cli
%{__install} -m 0755 redis-server %{buildroot}%{_sbindir}/redis-server
%{__install} -m 0644 redis.conf %{buildroot}%{_sysconfdir}/redis.conf
#
# init
#
%{__install} -m 0755 utils/redis_init_script %{buildroot}%{_sysconfdir}/init.d/redis
%{__ln_s} %{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
#
# logrotate
#
%{__install} -m 0644 %{S:1} \
%{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf %{buildroot}
%pre %pre
/usr/sbin/groupadd -r %{name} &>/dev/null || : /usr/sbin/groupadd -r %{name} &>/dev/null || :
/usr/sbin/useradd -o -g %{name} -s /bin/false -r -c "User for Redis key-value store" -d %{pkg_homedir} %{name} &>/dev/null || : /usr/sbin/useradd -o -g %{name} -s /bin/false -r -c "User for Redis key-value store" -d %{_home_dir} %{name} &>/dev/null || :
%post %post
%fillup_and_insserv %{name} %fillup_and_insserv %{name}
@ -84,14 +108,14 @@ rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%doc 00-RELEASENOTES BETATESTING.txt BUGS COPYING Changelog README TODO %doc 00-RELEASENOTES BETATESTING.txt BUGS COPYING Changelog README TODO
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_bindir}/redis-benchmark %{_bindir}/redis-benchmark
%{_bindir}/redis-cli %{_bindir}/redis-cli
%{_sbindir}/redis-server %{_sbindir}/redis-server
%{_sbindir}/rcredis %{_sbindir}/rc%{name}
%config(noreplace) %{_sysconfdir}/init.d/redis %config(noreplace) %{_sysconfdir}/init.d/redis
%config(noreplace) %attr(0640, %{name}, %{name}) %{_sysconfdir}/redis.conf %config(noreplace) %attr(0640, %{name}, %{name}) %{_sysconfdir}/redis.conf
%dir %attr(0750, %{name}, %{name}) %{pkg_homedir} %dir %attr(0750, %{name}, %{name}) %{_data_dir}
%dir %attr(0750, %{name}, %{name}) %{pkg_datadir}
%files doc %files doc
%defattr(-,root,root) %defattr(-,root,root)