A social knowledge tool for researchers built on ATProto
at main 845 B view raw
1#!/bin/bash 2 3# Check if Docker daemon is running 4if ! docker info > /dev/null 2>&1; then 5 echo "Error: Docker daemon is not running. Please start Docker and try again." 6 exit 1 7fi 8 9# Check if the Redis container is running 10if [ "$(docker ps -q -f name=annos-redis)" ]; then 11 echo "Redis container is already running." 12 export REDIS_RUNNING=true 13else 14 echo "Starting Redis container..." 15 npm run redis:start 16 export REDIS_RUNNING=false 17fi 18 19# Trap SIGINT and SIGTERM to stop containers on exit, only if we started them 20function cleanup_redis { 21 if [ "$REDIS_RUNNING" = false ]; then 22 if [ "$(docker ps -q -f name=annos-redis)" ]; then 23 echo "Stopping Redis container..." 24 npm run redis:stop 25 npm run redis:remove 26 fi 27 fi 28} 29 30# Export the cleanup function so it can be called from other scripts 31export -f cleanup_redis