Add templated redis

This commit is contained in:
2025-06-14 22:13:48 +02:00
parent 22994bb869
commit 21efcfc5ef
26 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,5 @@
redis
# Comment out remount-root and uncomment local-fs
# if you use separate partition for /tmp
remount-root
#local-fs

View File

@ -0,0 +1,2 @@
forbacktickx -E port { s6-instance-list /run/service/redis }
s6-instance-delete /run/service/redis $port

View File

@ -0,0 +1 @@
oneshot

View File

@ -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

View File

@ -0,0 +1,5 @@
network
# Comment out "remount-root" and uncomment "local-fs"
# if you use separate partition for /var
remount-root
#local-fs

1
rc.redis/redis/env/CMD vendored Normal file
View File

@ -0,0 +1 @@
s6-svscan

1
rc.redis/redis/env/CMD_OPTS vendored Normal file
View File

@ -0,0 +1 @@
-d3 -c500

View File

@ -0,0 +1 @@
3

27
rc.redis/redis/run Normal file
View File

@ -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

View File

@ -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

1
rc.redis/redis/template/env/CMD vendored Normal file
View File

@ -0,0 +1 @@
redis-server

1
rc.redis/redis/template/env/CMD_OPTS vendored Normal file
View File

@ -0,0 +1 @@
/etc/redis/${port}.conf

1
rc.redis/redis/template/log/env/CMD vendored Normal file
View File

@ -0,0 +1 @@
s6-log

View File

@ -0,0 +1 @@
-d3

View File

@ -0,0 +1,2 @@
root
# Logging directory group ownership

View File

@ -0,0 +1,2 @@
root
# Logging directory owner

View File

@ -0,0 +1,2 @@
/var/log/redis/${port}
# Logging directory path

View File

@ -0,0 +1,2 @@
750
# Logging directory access rights in octal

View File

@ -0,0 +1,2 @@
n4 s500000 T $LOGDIR_PATH
# Logging script used by s6-log

View File

@ -0,0 +1 @@
3

25
rc.redis/redis/template/log/run Executable file
View File

@ -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

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1 @@
3

17
rc.redis/redis/template/run Executable file
View File

@ -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

View File

@ -0,0 +1 @@
longrun

1
rc.redis/redis/type Normal file
View File

@ -0,0 +1 @@
longrun