diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2018-05-15 23:27:15 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2018-05-16 00:29:44 +0200 |
commit | 208b00c06d85cf7e7a9d349709ba73815d0a5c92 (patch) | |
tree | ce01a481509746e79c3efcc244a5c6710e104a35 /main/redis | |
parent | 47c81f33217bdd39084e1cfd784642122015a19c (diff) | |
download | aports-208b00c06d85cf7e7a9d349709ba73815d0a5c92.tar.bz2 aports-208b00c06d85cf7e7a9d349709ba73815d0a5c92.tar.xz |
main/redis: rewrite init script
Let OpenRC do its job!
Diffstat (limited to 'main/redis')
-rw-r--r-- | main/redis/APKBUILD | 17 | ||||
-rw-r--r-- | main/redis/redis.conf.patch | 53 | ||||
-rw-r--r-- | main/redis/redis.confd | 10 | ||||
-rw-r--r--[-rwxr-xr-x] | main/redis/redis.initd | 65 |
4 files changed, 88 insertions, 57 deletions
diff --git a/main/redis/APKBUILD b/main/redis/APKBUILD index 4dabb904cf..b924f36a2c 100644 --- a/main/redis/APKBUILD +++ b/main/redis/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: TBK <alpine@jjtc.eu> pkgname=redis pkgver=4.0.9 -pkgrel=0 +pkgrel=1 pkgdesc="Advanced key-value store" url="https://redis.io/" arch="all" @@ -15,6 +15,7 @@ checkdepends="tcl procps" install="redis.pre-install" subpackages="$pkgname-openrc" source="http://download.redis.io/releases/$pkgname-$pkgver.tar.gz + redis.conf.patch redis.initd redis.logrotate redis.confd @@ -23,19 +24,11 @@ builddir="$srcdir/$pkgname-$pkgver" prepare() { default_prepare - cd "$builddir" - sed -i -e 's|^daemonize .*|daemonize yes|' \ - -e 's|^dir .*|dir /var/lib/redis/|' \ - -e 's|^logfile .*|logfile /var/log/redis/redis\.log|' \ - -e 's|^pidfile .*|pidfile /var/run/redis/redis\.pid|' \ - -e 's|^loglevel .*|loglevel notice|' \ - redis.conf # disable broken tests # see: https://github.com/antirez/redis/issues/2814 # https://github.com/antirez/redis/issues/3810 - sed -i -e '/integration\/aof/d' \ -e '/integration\/logging/d' \ tests/test_helper.tcl @@ -60,7 +53,6 @@ package() { install -d -o redis -g redis \ "$pkgdir"/var/lib/redis \ "$pkgdir"/var/log/redis \ - "$pkgdir"/var/run/redis install -D -m755 "$builddir/COPYING" \ "$pkgdir/usr/share/licenses/redis/COPYING" @@ -77,6 +69,7 @@ package() { } sha512sums="a6cf63cb361f0a87da3955ba628190dc04cad342f7a664d18e44416ee67dd86ed6e3a46b9701e994f1417e56b819b3c6fc595f363c10bb4b83d5033919d29598 redis-4.0.9.tar.gz -91b663f802aea9a473195940d3bf2ce3ca2af4e5b6e61a2d28ebbfe502ef2c764b574b7e87c49e60345d1a5d6b73d12920924c93b26be110c2ce824023347b6f redis.initd +b97383f854f0fa7110f7d1f0fa5dd9d576c58e405f4fcc7e41c3c18fd0558599c5f5f5d215c797bc8d98aeb906ec96a1928ad8665d284b05c2d105adf8cecb7d redis.conf.patch +a56fdf8ac3f649ae1fa74005158be7d758a670ea02224519bc0000e7ce78e0c0f65a6166ced028f558461d03eba377fa37437d5e610b5ec3ed005d9e62eae25b redis.initd 6d17d169b40a7e23a0a2894eff0f3e2fe8e4461b36f2a9d45468f0abd84ea1035d679b4c0a34029bce093147f9c7bb697e843c113c17769d38c934d4a78a5848 redis.logrotate -d87aad6185300c99cc9b6a478c83bf62c450fb2c225592d74cc43a3adb93e19d8d2a42cc279907b385aa73a7b9c77b66828dbfb001009edc16a604abb2087e99 redis.confd" +6752e99df632b14d62a3266929e80c3d667be5c270e4f34e0dcf2b7f9b1754fe0ce9d4569fa413dbbe207e406ff2848a64e0c47629997536ae1d14ca84ebd56b redis.confd" diff --git a/main/redis/redis.conf.patch b/main/redis/redis.conf.patch new file mode 100644 index 0000000000..40608cb44a --- /dev/null +++ b/main/redis/redis.conf.patch @@ -0,0 +1,53 @@ +We force "daemonize no" in init script, so daemonize and pidfile does not +have any effect in redis.conf. It's init/rc system's job to daemonize +programs and handle pidfiles, if it needs it! + +--- a/redis.conf ++++ b/redis.conf +@@ -131,10 +131,6 @@ + + ################################# GENERAL ##################################### + +-# 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 +- + # If you run Redis from upstart or systemd, Redis can interact with your + # supervision tree. Options: + # supervised no - no supervision interaction +@@ -146,17 +142,6 @@ + # They do not enable continuous liveness pings back to your supervisor. + supervised no + +-# If a pid file is specified, Redis writes it where specified at startup +-# and removes it at exit. +-# +-# When the server runs non daemonized, no pid file is created if none is +-# specified in the configuration. When the server is daemonized, the pid file +-# is used even if not specified, defaulting to "/var/run/redis.pid". +-# +-# Creating a pid file is best effort: if Redis is not able to create it +-# nothing bad happens, the server will start and run normally. +-pidfile /var/run/redis_6379.pid +- + # Specify the server verbosity level. + # This can be one of: + # debug (a lot of information, useful for development/testing) +@@ -168,7 +153,7 @@ + # 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. +@@ -260,7 +245,7 @@ + # 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 ################################# + diff --git a/main/redis/redis.confd b/main/redis/redis.confd index a79f61ccdb..422145f4ec 100644 --- a/main/redis/redis.confd +++ b/main/redis/redis.confd @@ -1,9 +1,7 @@ -# Redis user. -REDIS_USER="redis" +# Configuration for /etc/init.d/redis -# Redis group. -REDIS_GROUP="redis" +# User (and group) to run redis as. +#command_user="redis:redis" # Redis configuration file. -REDIS_CONF="/etc/redis.conf" - +#cfgfile="/etc/redis.conf" diff --git a/main/redis/redis.initd b/main/redis/redis.initd index ce6aba7e33..386b6e0af8 100755..100644 --- a/main/redis/redis.initd +++ b/main/redis/redis.initd @@ -1,52 +1,39 @@ #!/sbin/openrc-run -REDIS_CONF=${REDIS_CONF:-/etc/redis.conf} -REDIS_USER=${REDIS_USER:-redis} -REDIS_GROUP=${REDIS_GROUP:-redis} - name="Redis server" -command=/usr/bin/redis-server -command_args=${REDIS_CONF} + +: ${cfgfile:=${REDIS_CONF:-"/etc/redis.conf"}} +: ${command_user:="${REDIS_USER:-redis}:${REDIS_GROUP:-redis}"} +: ${retry:=30} + +command="/usr/bin/redis-server" +command_args="$cfgfile --daemonize no $command_args" +command_background="yes" +pidfile="/run/$RC_SVCNAME.pid" + +required_files="$cfgfile" depend() { use net localmount logger after keepalived firewall } -# 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} -} +start_pre() { + # Sets start-start-daemon's --chdir. + directory=$(config_get 'dir' '/var/lib/redis') + checkpath -d -o "$command_user" "$directory" -start() { - get_config || return 1 - checkpath -d -o ${REDIS_USER}:${REDIS_GROUP} ${pidfile%/*} \ - ${logfile%/*} ${dir} - - ebegin "Starting $name" - start-stop-daemon --start \ - --chdir "${dir}" \ - --user ${REDIS_USER}:${REDIS_GROUP} \ - --pidfile "${pidfile}" \ - --exec "${command}" \ - -- ${command_args} - eend $? -} + local logfile=$(config_get 'logfile') + [ "$logfile" ] && checkpath -d -o "$command_user" "${logfile%/*}" -stop() { - get_config - ebegin "Stopping $name" - start-stop-daemon --stop --retry 30 --pidfile "${pidfile}" - eend $? + local unixsocket=$(config_get 'unixsocket') + [ "$unixsocket" ] && checkpath -d -o "$command_user" "${unixsocket%/*}" } +config_get() { + local key="$1" + local default="${2:-}" + + local value=$(awk "\$1 == \"$key\" { print \$2 }" "$cfgfile") + printf '%s\n' "${value:-$default}" +} |