Skip to content

Commit 1161217

Browse files
committed
feat(stacks): add redis-sentinel add redis.conf
1 parent 79f3e12 commit 1161217

3 files changed

Lines changed: 85 additions & 1 deletion

File tree

scripts/checker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@
181181
"owner": "redis",
182182
"match": "^[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}$",
183183
},
184+
"redis-sentinel": {
185+
"name": "redis",
186+
"type": "github",
187+
"owner": "redis",
188+
"match": "^[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}$",
189+
},
184190
"registry": {
185191
"name": "distribution",
186192
"type": "github",

stacks/redis-sentinel/build.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
# Load stack utils
4+
. /usr/bin/stack-utils
5+
6+
# Implement build function
7+
function build() {
8+
# Generate binary
9+
REDIS_DOWNLOAD_URL="http://download.redis.io/releases/redis-${STACK_VERSION}.tar.gz"
10+
savedAptMark="$(apt-mark showmanual)"; \
11+
curl -fsSL -o redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
12+
mkdir -p /usr/src/redis; \
13+
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
14+
rm redis.tar.gz; \
15+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \
16+
sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \
17+
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \
18+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
19+
extraJemallocConfigureFlags="--build=$gnuArch"; \
20+
# https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
21+
dpkgArch="$(dpkg --print-architecture)"; \
22+
case "${dpkgArch##*-}" in \
23+
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \
24+
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \
25+
esac; \
26+
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \
27+
grep -F 'cd jemalloc && ./configure ' /usr/src/redis/deps/Makefile; \
28+
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/redis/deps/Makefile; \
29+
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \
30+
\
31+
export BUILD_TLS=yes; \
32+
make -C /usr/src/redis -j "$(nproc)" all; \
33+
make -C /usr/src/redis PREFIX=/opt/drycc/redis-sentinel install; \
34+
\
35+
# TODO https://github.com/redis/redis/pull/3494 (deduplicate "redis-server" copies)
36+
serverMd5="$(md5sum /opt/drycc/redis-sentinel/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \
37+
find /opt/drycc/redis-sentinel/bin/redis* -maxdepth 0 \
38+
-type f -not -name redis-server \
39+
-exec sh -eux -c ' \
40+
md5="$(md5sum "$1" | cut -d" " -f1)"; \
41+
test "$md5" = "$serverMd5"; \
42+
' -- '{}' ';' \
43+
-exec ln -svfT 'redis-server' '{}' ';' \
44+
; \
45+
\
46+
rm -r /usr/src/redis; \
47+
\
48+
apt-mark auto '.*' > /dev/null; \
49+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
50+
find /opt/drycc/redis-sentinel/bin -type f -executable -exec ldd '{}' ';' \
51+
| awk '/=>/ { print $(NF-1) }' \
52+
| sort -u \
53+
| xargs -r dpkg-query --search \
54+
| cut -d: -f1 \
55+
| sort -u \
56+
| xargs -r apt-mark manual \
57+
; \
58+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
59+
\
60+
/opt/drycc/redis-sentinel/bin/redis-cli --version; \
61+
/opt/drycc/redis-sentinel/bin/redis-server --version
62+
63+
chmod +x /opt/drycc/redis-sentinel/bin/redis*
64+
mkdir -p "${PROFILE_DIR}"
65+
cat << EOF > "${PROFILE_DIR}/${STACK_NAME}.sh"
66+
export PATH="/opt/drycc/redis-sentinel/bin:\$PATH"
67+
EOF
68+
cp -rf /opt/drycc/redis-sentinel/* "${DATA_DIR}"
69+
REDIS_MAJOR_VERSION=$(echo "${STACK_VERSION}" | awk -F "." '{print ""$1"."$2""}')
70+
mkdir -p "${DATA_DIR}"/etc && \
71+
curl -fsSL -o "${DATA_DIR}"/etc/sentinel.conf https://raw.githubusercontent.com/redis/redis/"${REDIS_MAJOR_VERSION}"/sentinel.conf
72+
}
73+
74+
# call build stack
75+
build-stack "${1}"

stacks/redis/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ function build() {
6666
export PATH="/opt/drycc/redis/bin:\$PATH"
6767
EOF
6868
cp -rf /opt/drycc/redis/* "${DATA_DIR}"
69+
REDIS_MAJOR_VERSION=$(echo "${STACK_VERSION}" | awk -F "." '{print ""$1"."$2""}')
70+
mkdir -p "${DATA_DIR}"/etc && \
71+
curl -fsSL -o "${DATA_DIR}"/etc/redis-default.conf https://raw.githubusercontent.com/redis/redis/"${REDIS_MAJOR_VERSION}"/redis.conf
6972
}
7073

7174
# call build stack
72-
build-stack "${1}"
75+
build-stack "${1}"

0 commit comments

Comments
 (0)