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:
5
redis/dockerdata/.gitignore
vendored
5
redis/dockerdata/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*
|
||||
!lock\
|
||||
lock\redis-cluster-init.lock
|
||||
!lock/
|
||||
lock/*
|
||||
!lock/.gitkeep
|
||||
|
||||
0
redis/dockerdata/lock/.gitkeep
Normal file
0
redis/dockerdata/lock/.gitkeep
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user