Pavol Rusnak 2010-03-07 23:22:27 +00:00 committed by Git OBS Bridge
parent 4e1042c7e2
commit 4fe712f1b5
3 changed files with 35 additions and 12 deletions

View File

@ -11,3 +11,12 @@ Index: redis.conf
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default. # When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
# You can specify a custom pid file location here. # You can specify a custom pid file location here.
@@ -64,7 +64,7 @@ dbfilename dump.rdb
# For default save/load DB in/from the working directory
# Note that you must specify a directory not a file name.
-dir ./
+dir /var/lib/redis/
################################# REPLICATION #################################

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,28 +1,39 @@ @@ -1,28 +1,44 @@
#!/bin/sh #!/bin/sh
+### BEGIN INIT INFO +### BEGIN INIT INFO
+# Provides: redis +# Provides: redis
@ -24,45 +24,57 @@ Index: utils/redis_init_script
-CONF="/etc/redis/${REDISPORT}.conf" -CONF="/etc/redis/${REDISPORT}.conf"
+PIDFILE=/var/run/redis.pid +PIDFILE=/var/run/redis.pid
+CONF=/etc/redis.conf +CONF=/etc/redis.conf
+
+. /etc/rc.status
case "$1" in case "$1" in
start) start)
if [ -f $PIDFILE ] if [ -f $PIDFILE ]
then then
- echo -n "$PIDFILE exists, process is already running or crashed\n" - echo -n "$PIDFILE exists, process is already running or crashed\n"
+ echo "$PIDFILE exists, process is already running or crashed" + echo -n "$PIDFILE exists, process is already running or crashed"
+ rc_failed
else else
- echo -n "Starting Redis server...\n" - echo -n "Starting Redis server...\n"
+ echo "Starting Redis server..." + echo -n "Starting Redis server..."
$EXEC $CONF $EXEC $CONF
+ rc_status -v
fi fi
;; ;;
stop) stop)
if [ ! -f $PIDFILE ] if [ ! -f $PIDFILE ]
then then
- echo -n "$PIDFILE does not exist, process is not running\n" - echo -n "$PIDFILE does not exist, process is not running\n"
+ echo "$PIDFILE does not exist, process is not running" + echo -n "$PIDFILE does not exist, process is not running"
+ rc_failed
else else
- echo -n "Stopping ...\n" - echo -n "Stopping ...\n"
- echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT & - echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT &
+ echo "Stopping ..." + echo -n "Stopping ..."
+ echo -e "SHUTDOWN\r" | netcat localhost $REDISPORT & + echo -e "SHUTDOWN\r" | netcat localhost $REDISPORT &
PID=$(cat $PIDFILE) PID=$(cat $PIDFILE)
while [ -x /proc/${PIDFILE} ] while [ -x /proc/${PIDFILE} ]
do do
@@ -33,4 +44,15 @@ case "$1" in @@ -31,6 +47,22 @@ case "$1" in
done
rm $PIDFILE
echo "Redis stopped" echo "Redis stopped"
fi + rc_status -v
;; + fi
+ ;;
+ status) + status)
+ if [ ! -f $PIDFILE ] + if [ ! -f $PIDFILE ]
+ then + then
+ echo "$PIDFILE does not exist, process is not running" + echo -n "$PIDFILE does not exist, process is not running"
+ rc_status -v
+ else + else
+ echo "$PIDFILE does exist, process is running" + echo -n "$PIDFILE does exist, process is running"
+ fi + rc_status -v
+ ;; fi
;;
+ *) + *)
+ echo "Usage: $0 [start|stop|status]" + echo "Usage: $0 [start|stop|status]"
+ ;; + ;;
esac esac
+
+rc_exit

View File

@ -59,6 +59,7 @@ install -D -m 0755 redis-server $RPM_BUILD_ROOT%{_sbindir}/redis-server
install -D -m 0755 utils/redis_init_script $RPM_BUILD_ROOT%{_sysconfdir}/init.d/redis install -D -m 0755 utils/redis_init_script $RPM_BUILD_ROOT%{_sysconfdir}/init.d/redis
ln -s %{_sysconfdir}/init.d/redis $RPM_BUILD_ROOT%{_sbindir}/rcredis ln -s %{_sysconfdir}/init.d/redis $RPM_BUILD_ROOT%{_sbindir}/rcredis
install -D -m 0644 redis.conf $RPM_BUILD_ROOT%{_sysconfdir}/redis.conf install -D -m 0644 redis.conf $RPM_BUILD_ROOT%{_sysconfdir}/redis.conf
mkdir -p $RPM_BUILD_ROOT/var/lib/redis
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -72,6 +73,7 @@ rm -rf $RPM_BUILD_ROOT
%{_sysconfdir}/init.d/redis %{_sysconfdir}/init.d/redis
%{_sbindir}/rcredis %{_sbindir}/rcredis
%config(noreplace) %{_sysconfdir}/redis.conf %config(noreplace) %{_sysconfdir}/redis.conf
%dir /var/lib/redis
%files doc %files doc
%defattr(-,root,root) %defattr(-,root,root)