···11#!/bin/bash
2233-# 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
33+# Source the Redis setup script
44+source ./scripts/setup-redis.sh
1851919-# 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
66+# Trap SIGINT and SIGTERM to cleanup on exit
77+trap cleanup_redis SIGINT SIGTERM
308319# Run the feed worker dev command
3210npm run dev:worker:feeds
33113412# Cleanup after dev command exits
3535-cleanup
1313+cleanup_redis
+5-28
scripts/dev.sh
···11#!/bin/bash
2233-# 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
33+# Source the Postgres setup script
44+source ./scripts/setup-postgres.sh
8599-# Check if the Postgres container is running
1010-if [ "$(docker ps -q -f name=annos-postgres)" ]; then
1111- echo "Postgres container is already running."
1212- DB_RUNNING=true
1313-else
1414- echo "Starting Postgres container..."
1515- npm run db:start
1616- DB_RUNNING=false
1717-fi
1818-1919-2020-# Trap SIGINT and SIGTERM to stop containers on exit, only if we started them
2121-function cleanup {
2222- if [ "$DB_RUNNING" = false ]; then
2323- if [ "$(docker ps -q -f name=annos-postgres)" ]; then
2424- echo "Stopping Postgres container..."
2525- npm run db:stop
2626- npm run db:remove
2727- fi
2828- fi
2929-}
3030-trap cleanup SIGINT SIGTERM
66+# Trap SIGINT and SIGTERM to cleanup on exit
77+trap cleanup_postgres SIGINT SIGTERM
318329# Run the dev command
3310npm run dev:inner
34113512# Cleanup after dev command exits
3636-cleanup
1313+cleanup_postgres
+31
scripts/setup-postgres.sh
···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 Postgres container is running
1010+if [ "$(docker ps -q -f name=annos-postgres)" ]; then
1111+ echo "Postgres container is already running."
1212+ export DB_RUNNING=true
1313+else
1414+ echo "Starting Postgres container..."
1515+ npm run db:start
1616+ export DB_RUNNING=false
1717+fi
1818+1919+# Trap SIGINT and SIGTERM to stop containers on exit, only if we started them
2020+function cleanup_postgres {
2121+ if [ "$DB_RUNNING" = false ]; then
2222+ if [ "$(docker ps -q -f name=annos-postgres)" ]; then
2323+ echo "Stopping Postgres container..."
2424+ npm run db:stop
2525+ npm run db:remove
2626+ fi
2727+ fi
2828+}
2929+3030+# Export the cleanup function so it can be called from other scripts
3131+export -f cleanup_postgres
+31
scripts/setup-redis.sh
···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+ export REDIS_RUNNING=true
1313+else
1414+ echo "Starting Redis container..."
1515+ npm run redis:start
1616+ export REDIS_RUNNING=false
1717+fi
1818+1919+# Trap SIGINT and SIGTERM to stop containers on exit, only if we started them
2020+function cleanup_redis {
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+3030+# Export the cleanup function so it can be called from other scripts
3131+export -f cleanup_redis