diff options
Diffstat (limited to 'testing/redis/redis.initd')
-rwxr-xr-x[-rw-r--r--] | testing/redis/redis.initd | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/testing/redis/redis.initd b/testing/redis/redis.initd index a23bcc774e..3c4b7901c4 100644..100755 --- a/testing/redis/redis.initd +++ b/testing/redis/redis.initd @@ -1,42 +1,53 @@ #!/sbin/runscript -REDIS_EXEC=/usr/bin/redis-server -REDIS_PID=${REDIS_PID:-/var/run/redis.pid} -REDIS_DIR=${REDIS_DIR:-/var/lib/redis} REDIS_CONF=${REDIS_CONF:-/etc/redis.conf} -REDIS_OPTS=${REDIS_OPTS:-"${REDIS_CONF}"} REDIS_USER=${REDIS_USER:-redis} REDIS_GROUP=${REDIS_GROUP:-redis} -REDIS_PORT=${REDIS_PORT:-6379} -REDIS_CLIEXEC=/usr/bin/redis-cli + +name="Redis server" +command=/usr/bin/redis-server +command_args=${REDIS_CONF} depend() { use net localmount logger after keepalived firewall } -start() { +# get global pidfile, logfile, and dir from config file +get_config() { + if [ ! -f "${REDIS_CONF}" ] ; then + eerror "You need a ${REDIS_CONF} file to run redis" + return 1; + fi + + pidfile=$(awk '$1 == "pidfile" { print $2 }' "$REDIS_CONF") + logfile=$(awk '$1 == "logfile" { print $2 }' "$REDIS_CONF") + dir=$(awk '$1 == "dir" { print $2 }' "$REDIS_CONF") + : ${pidfile:=/var/run/redis/redis.pid} + : ${logfile:=/var/log/redis/redis.log} + : ${dir:=/var/lib/redis} +} - local PID_DIR=$(dirname ${REDIS_PID}) - checkpath -d -o ${REDIS_USER}:${REDIS_GROUP} ${PID_DIR} +start() { + get_config || return 1 + checkpath -d -o ${REDIS_USER}:${REDIS_GROUP} ${pidfile%/*} \ + ${logfile%/*} ${dir} - ebegin "Starting Redis server" + ebegin "Starting $name" start-stop-daemon --start \ - --chdir "${REDIS_DIR}" \ + --chdir "${dir}" \ --user ${REDIS_USER}:${REDIS_GROUP} \ - --pidfile "${REDIS_PID}" \ - --exec "${REDIS_EXEC}" \ - -- ${REDIS_OPTS} - ret=$? - eend ${ret} - + --pidfile "${pidfile}" \ + --exec "${command}" \ + -- ${command_args} + eend $? } -stop() { - ebegin "Stopping Redis server" - start-stop-daemon --stop --quiet --pidfile "${REDIS_PID}" - ret=$? - rm -f "${REDIS_PID}" - eend ${ret} +stop_post() { + get_config + ebegin "Stopping $name" + start-stop-daemon --stop --quiet --pidfile "${pidfile}" \ + && rm -f "${pidfile}" + eend $? } |