docker-redis - improve lockfile for redis, add redis-insights, make sure app image has all it needs to build canvas

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-10-03 13:17:04 -04:00
parent 8f312bfffb
commit 68b8743002
5 changed files with 52 additions and 18 deletions

View File

@@ -1,3 +1,4 @@
*
!lock\
lock\redis-cluster-init.lock
!lock/
lock/*
!lock/.gitkeep

View File

View File

@@ -1,19 +1,35 @@
#!/bin/sh
LOCKFILE="/redis-lock/redis-cluster-init.lock"
# Start Redis server in the background
redis-server /usr/local/etc/redis/redis.conf &
# Wait for Redis server to start
sleep 5
# Only initialize the cluster from one node to prevent race conditions
if [ "$HOSTNAME" = "redis-node-1" ]; then
# Only initialize the cluster if the lock file doesn't exist
if [ ! -f "$LOCKFILE" ]; then
echo "Initializing Redis Cluster..."
# Create lock file to prevent further initialization attempts
touch "$LOCKFILE"
if [ $? -eq 0 ]; then
echo "Lock file created successfully at $LOCKFILE."
else
echo "Failed to create lock file."
fi
# Initialize the Redis cluster
yes yes | redis-cli --cluster create \
redis-node-1:6379 \
redis-node-2:6379 \
redis-node-3:6379 \
--cluster-replicas 0
echo "Redis Cluster initialized."
else
echo "Cluster already initialized, skipping initialization."
fi
# Keep the container running