A social knowledge tool for researchers built on ATProto

chore: improve dev script cleanup and Docker container management

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

+1 -1
package.json
··· 27 27 "dev:worker:feeds:inner": "dotenv -e .env.local -- concurrently -k -n WORKER -c green \"tsup --watch --onSuccess='node dist/workers/feed-worker.js'\"", 28 28 "dev:mock": "USE_MOCK_REPOS=true USE_FAKE_PUBLISHERS=true USE_MOCK_AUTH=true npm run dev:inner", 29 29 "dev:mock:pub:auth": "USE_FAKE_PUBLISHERS=true USE_MOCK_AUTH=true npm run dev", 30 - "dev": "concurrently -k -n APP,WORKER -c blue,green \"bash ./scripts/dev-feed-worker.sh\" \"bash ./scripts/dev.sh\"", 30 + "dev": "bash ./scripts/dev-combined.sh", 31 31 "migrate": "node dist/scripts/migrate.js", 32 32 "lexgen": "lex gen-server ./src/modules/atproto/infrastructure/lexicon ./src/modules/atproto/infrastructure/lexicons/*", 33 33 "db:start": "docker run --name annos-postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=annotations -p 5432:5432 -d postgres:14",
+25
scripts/dev-combined.sh
··· 1 + #!/bin/bash 2 + 3 + # Source both setup scripts 4 + source ./scripts/setup-postgres.sh 5 + source ./scripts/setup-redis.sh 6 + 7 + # Function to handle cleanup for both services 8 + cleanup_and_exit() { 9 + echo "Cleaning up services..." 10 + cleanup_postgres 11 + cleanup_redis 12 + exit 0 13 + } 14 + 15 + # Trap SIGINT and SIGTERM to cleanup on exit 16 + trap cleanup_and_exit SIGINT SIGTERM 17 + 18 + # Run both services with concurrently 19 + concurrently -k -n APP,WORKER -c blue,green \ 20 + "dotenv -e .env.local -- concurrently -k -n TYPE,APP -c red,blue \"tsc --noEmit --watch\" \"tsup --watch --onSuccess='node dist/index.js'\"" \ 21 + "dotenv -e .env.local -- concurrently -k -n WORKER -c green \"tsup --watch --onSuccess='node dist/workers/feed-worker.js'\"" 22 + 23 + # Cleanup after concurrently exits 24 + cleanup_postgres 25 + cleanup_redis
+15 -10
scripts/dev-feed-worker.sh
··· 3 3 # Source the Redis setup script 4 4 source ./scripts/setup-redis.sh 5 5 6 - # Function to handle cleanup 7 - cleanup_and_exit() { 8 - echo "Cleaning up Redis..." 9 - cleanup_redis 10 - exit 0 11 - } 6 + # Only setup cleanup if not running from combined script 7 + if [ -z "$COMBINED_SCRIPT" ]; then 8 + # Function to handle cleanup 9 + cleanup_and_exit() { 10 + echo "Cleaning up Redis..." 11 + cleanup_redis 12 + exit 0 13 + } 12 14 13 - # Trap SIGINT and SIGTERM to cleanup on exit 14 - trap cleanup_and_exit SIGINT SIGTERM 15 + # Trap SIGINT and SIGTERM to cleanup on exit 16 + trap cleanup_and_exit SIGINT SIGTERM 17 + fi 15 18 16 19 # Run the feed worker dev command 17 20 npm run dev:worker:feeds:inner 18 21 19 - # Cleanup after dev command exits 20 - cleanup_redis 22 + # Only cleanup if not running from combined script 23 + if [ -z "$COMBINED_SCRIPT" ]; then 24 + cleanup_redis 25 + fi
+15 -10
scripts/dev.sh
··· 3 3 # Source the Postgres setup script 4 4 source ./scripts/setup-postgres.sh 5 5 6 - # Function to handle cleanup 7 - cleanup_and_exit() { 8 - echo "Cleaning up Postgres..." 9 - cleanup_postgres 10 - exit 0 11 - } 6 + # Only setup cleanup if not running from combined script 7 + if [ -z "$COMBINED_SCRIPT" ]; then 8 + # Function to handle cleanup 9 + cleanup_and_exit() { 10 + echo "Cleaning up Postgres..." 11 + cleanup_postgres 12 + exit 0 13 + } 12 14 13 - # Trap SIGINT and SIGTERM to cleanup on exit 14 - trap cleanup_and_exit SIGINT SIGTERM 15 + # Trap SIGINT and SIGTERM to cleanup on exit 16 + trap cleanup_and_exit SIGINT SIGTERM 17 + fi 15 18 16 19 # Run the dev command 17 20 npm run dev:app:inner 18 21 19 - # Cleanup after dev command exits 20 - cleanup_postgres 22 + # Only cleanup if not running from combined script 23 + if [ -z "$COMBINED_SCRIPT" ]; then 24 + cleanup_postgres 25 + fi