···11+#!/bin/bash
22+33+# Check if Docker daemon is running
44+if ! docker info > /dev/null 2>&1; then
55+ echo "Error: Docker daemon is not running. Please start Docker and try again."
66+ exit 1
77+fi
88+99+# Check if the Redis container is running
1010+if [ "$(docker ps -q -f name=annos-redis)" ]; then
1111+ echo "Redis container is already running."
1212+ REDIS_RUNNING=true
1313+else
1414+ echo "Starting Redis container..."
1515+ npm run redis:start
1616+ REDIS_RUNNING=false
1717+fi
1818+1919+# Trap SIGINT and SIGTERM to stop containers on exit, only if we started them
2020+function cleanup {
2121+ if [ "$REDIS_RUNNING" = false ]; then
2222+ if [ "$(docker ps -q -f name=annos-redis)" ]; then
2323+ echo "Stopping Redis container..."
2424+ npm run redis:stop
2525+ npm run redis:remove
2626+ fi
2727+ fi
2828+}
2929+trap cleanup SIGINT SIGTERM
3030+3131+# Run the feed worker dev command
3232+npm run dev:worker:feeds
3333+3434+# Cleanup after dev command exits
3535+cleanup