diff --git a/rc.redis/redis-instances/dependencies b/rc.redis/redis-instances/dependencies new file mode 100644 index 0000000..66eafdd --- /dev/null +++ b/rc.redis/redis-instances/dependencies @@ -0,0 +1,5 @@ +redis +# Comment out remount-root and uncomment local-fs +# if you use separate partition for /tmp +remount-root +#local-fs diff --git a/rc.redis/redis-instances/down b/rc.redis/redis-instances/down new file mode 100644 index 0000000..8e82be6 --- /dev/null +++ b/rc.redis/redis-instances/down @@ -0,0 +1,2 @@ +forbacktickx -E port { s6-instance-list /run/service/redis } +s6-instance-delete /run/service/redis $port diff --git a/rc.redis/redis-instances/type b/rc.redis/redis-instances/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/rc.redis/redis-instances/type @@ -0,0 +1 @@ +oneshot diff --git a/rc.redis/redis-instances/up b/rc.redis/redis-instances/up new file mode 100644 index 0000000..2e7ed25 --- /dev/null +++ b/rc.redis/redis-instances/up @@ -0,0 +1,9 @@ +######################################################### +# Create redis instances with existing configuration # +# files. # +######################################################### + +elglob -0 configs /etc/redis/[0-9]*.conf +forx -E config { $configs } +backtick -E port { basename $config .conf } +s6-instance-create /run/service/redis $port diff --git a/rc.redis/redis/dependencies b/rc.redis/redis/dependencies new file mode 100644 index 0000000..8a3e02f --- /dev/null +++ b/rc.redis/redis/dependencies @@ -0,0 +1,5 @@ +network +# Comment out "remount-root" and uncomment "local-fs" +# if you use separate partition for /var +remount-root +#local-fs diff --git a/rc.redis/redis/env/CMD b/rc.redis/redis/env/CMD new file mode 100644 index 0000000..468ffed --- /dev/null +++ b/rc.redis/redis/env/CMD @@ -0,0 +1 @@ +s6-svscan diff --git a/rc.redis/redis/env/CMD_OPTS b/rc.redis/redis/env/CMD_OPTS new file mode 100644 index 0000000..e976272 --- /dev/null +++ b/rc.redis/redis/env/CMD_OPTS @@ -0,0 +1 @@ +-d3 -c500 diff --git a/rc.redis/redis/notification-fd b/rc.redis/redis/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/rc.redis/redis/notification-fd @@ -0,0 +1 @@ +3 diff --git a/rc.redis/redis/run b/rc.redis/redis/run new file mode 100644 index 0000000..8c8a426 --- /dev/null +++ b/rc.redis/redis/run @@ -0,0 +1,27 @@ +#!/bin/execlineb -P + +########################################################################### +# Start redis instance supervisor # +# # +# The redis instances are run by the redis user. Database directory is # +# owned by that user and the redis group. You can create these with: # +# # +# groupadd -g 121 redis # +# useradd -u 121 -g 121 -d /var/lib/redis -s /sbin/nologin redis # +# # +# The configuration for redis instances is expected to be named same as # +# port the instance will be running on. For example if redis should # +# listen on 6379, there should be a configuration file in # +# /etc/redis/6379.conf. Generic settings can be put in # +# /etc/redis/redis.conf and included in other configurations. s6 instance # +# name should be the port number as well, 6379 in this case. # +########################################################################### + +fdmove -c 2 1 +foreground { chown redis:redis /var/lib/redis } +s6-envdir env +multisubstitute { + importas -u CMD CMD + importas -usCd" " CMD_OPTS CMD_OPTS +} +emptyenv -p $CMD $CMD_OPTS -- instance diff --git a/rc.redis/redis/template/data/check b/rc.redis/redis/template/data/check new file mode 100755 index 0000000..8bdc4ba --- /dev/null +++ b/rc.redis/redis/template/data/check @@ -0,0 +1,7 @@ +#!/bin/execlineb -P + +redirfd -w 2 /dev/null +getcwd -E CWD +backtick -E port { basename $CWD } +backtick -En PING { redis-cli -p $port ping } +eltest $PING = PONG diff --git a/rc.redis/redis/template/env/CMD b/rc.redis/redis/template/env/CMD new file mode 100644 index 0000000..20a006a --- /dev/null +++ b/rc.redis/redis/template/env/CMD @@ -0,0 +1 @@ +redis-server diff --git a/rc.redis/redis/template/env/CMD_OPTS b/rc.redis/redis/template/env/CMD_OPTS new file mode 100644 index 0000000..35b0eaa --- /dev/null +++ b/rc.redis/redis/template/env/CMD_OPTS @@ -0,0 +1 @@ +/etc/redis/${port}.conf diff --git a/rc.redis/redis/template/log/env/CMD b/rc.redis/redis/template/log/env/CMD new file mode 100644 index 0000000..9d5239c --- /dev/null +++ b/rc.redis/redis/template/log/env/CMD @@ -0,0 +1 @@ +s6-log diff --git a/rc.redis/redis/template/log/env/CMD_OPTS b/rc.redis/redis/template/log/env/CMD_OPTS new file mode 100644 index 0000000..00d672e --- /dev/null +++ b/rc.redis/redis/template/log/env/CMD_OPTS @@ -0,0 +1 @@ +-d3 diff --git a/rc.redis/redis/template/log/env/LOGDIR_GROUP b/rc.redis/redis/template/log/env/LOGDIR_GROUP new file mode 100644 index 0000000..3794bcd --- /dev/null +++ b/rc.redis/redis/template/log/env/LOGDIR_GROUP @@ -0,0 +1,2 @@ +root +# Logging directory group ownership diff --git a/rc.redis/redis/template/log/env/LOGDIR_OWNER b/rc.redis/redis/template/log/env/LOGDIR_OWNER new file mode 100644 index 0000000..9f9fd12 --- /dev/null +++ b/rc.redis/redis/template/log/env/LOGDIR_OWNER @@ -0,0 +1,2 @@ +root +# Logging directory owner diff --git a/rc.redis/redis/template/log/env/LOGDIR_PATH b/rc.redis/redis/template/log/env/LOGDIR_PATH new file mode 100644 index 0000000..5bd5897 --- /dev/null +++ b/rc.redis/redis/template/log/env/LOGDIR_PATH @@ -0,0 +1,2 @@ +/var/log/redis/${port} +# Logging directory path diff --git a/rc.redis/redis/template/log/env/LOGDIR_PERMS b/rc.redis/redis/template/log/env/LOGDIR_PERMS new file mode 100644 index 0000000..ccece6e --- /dev/null +++ b/rc.redis/redis/template/log/env/LOGDIR_PERMS @@ -0,0 +1,2 @@ +750 +# Logging directory access rights in octal diff --git a/rc.redis/redis/template/log/env/LOG_SCRIPT b/rc.redis/redis/template/log/env/LOG_SCRIPT new file mode 100644 index 0000000..948a563 --- /dev/null +++ b/rc.redis/redis/template/log/env/LOG_SCRIPT @@ -0,0 +1,2 @@ +n4 s500000 T $LOGDIR_PATH +# Logging script used by s6-log diff --git a/rc.redis/redis/template/log/notification-fd b/rc.redis/redis/template/log/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/rc.redis/redis/template/log/notification-fd @@ -0,0 +1 @@ +3 diff --git a/rc.redis/redis/template/log/run b/rc.redis/redis/template/log/run new file mode 100755 index 0000000..f05f9eb --- /dev/null +++ b/rc.redis/redis/template/log/run @@ -0,0 +1,25 @@ +#!/bin/execlineb -WS1 + +############################################### +# Start a logging daemon for the redis daemon # +############################################### + +s6-envdir env +multisubstitute { + importas -iu LOGDIR_OWNER LOGDIR_OWNER + importas -iu LOGDIR_GROUP LOGDIR_GROUP + importas -iu LOGDIR_PERMS LOGDIR_PERMS + importas -iu CMD CMD + importas -usCd" " CMD_OPTS CMD_OPTS + importas -iusCd" " LOG_SCRIPT LOG_SCRIPT +} +s6-envuidgid -Bi ${LOGDIR_OWNER}:${LOGDIR_GROUP} +multisubstitute { + importas -iu LOGDIR_PATH LOGDIR_PATH + importas -iu UID UID + importas -iu GID GID +} +backtick -E port { dirname $1 } +if { install -dm $LOGDIR_PERMS -o $UID -g $GID $LOGDIR_PATH } +s6-setuidgid ${UID}:${GID} +exec -c $CMD $CMD_OPTS -- $LOG_SCRIPT diff --git a/rc.redis/redis/template/log/type b/rc.redis/redis/template/log/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rc.redis/redis/template/log/type @@ -0,0 +1 @@ +longrun diff --git a/rc.redis/redis/template/notification-fd b/rc.redis/redis/template/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/rc.redis/redis/template/notification-fd @@ -0,0 +1 @@ +3 diff --git a/rc.redis/redis/template/run b/rc.redis/redis/template/run new file mode 100755 index 0000000..cdd0b58 --- /dev/null +++ b/rc.redis/redis/template/run @@ -0,0 +1,17 @@ +#!/bin/execlineb -WS1 + +################################# +# Start redis (key-value store) # +################################# + +fdmove -c 2 1 +s6-envdir env +multisubstitute { + importas -iu CMD CMD + importas -usCd" " CMD_OPTS CMD_OPTS +} +prlimit --nofile=8192 +define port $1 +s6-notifyoncheck -d +s6-setuidgid redis +exec -c $CMD $CMD_OPTS diff --git a/rc.redis/redis/template/type b/rc.redis/redis/template/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rc.redis/redis/template/type @@ -0,0 +1 @@ +longrun diff --git a/rc.redis/redis/type b/rc.redis/redis/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rc.redis/redis/type @@ -0,0 +1 @@ +longrun