Skip to content

Instantly share code, notes, and snippets.

@sairam
Last active October 16, 2018 17:29
Show Gist options
  • Save sairam/5890826 to your computer and use it in GitHub Desktop.
Save sairam/5890826 to your computer and use it in GitHub Desktop.
Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. This works on Fedora. After adding the description for chkconfig the error "service redis_6379 does not support chkconfig" disappeared.
#!/bin/sh
#
# redis - this script starts and stops the redis daemon
#
# chkconfig: - 85 15
# description: Redis is an open source, BSD licensed, advanced \
# key-value store. It is often referred to as a \
# data structure server since keys can contain \
# strings, hashes, lists, sets and sorted sets.
# processname: redis
# config: /etc/redis/6379.conf
# pidfile: /varn/run/redis_6379.pid
# user: root
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis_6379.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/redis/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
@BlakeGardner
Copy link

You saved me with this, thanks!

@hugohenley
Copy link

Thanks! Saved me too!

@akotlov
Copy link

akotlov commented Aug 16, 2017

Thank you,worked for me.

@ouadi
Copy link

ouadi commented Aug 28, 2017

Very small fix. Line 12 should be # pidfile: /var/run/redis_6379.pid instead of # pidfile: /varn/run/redis_6379.pid (no n in /var).
Thank you for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment