From 32983da29cc15c8a3aca3e608c11e01b0a74fb4d Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 20 Feb 2025 09:06:54 +0000 Subject: [PATCH] Merge pull request #23700 from overleaf/bg-history-redis add redis to history-v1 GitOrigin-RevId: def900c4b560ea0a297b11b6c0ecc8cc8caa5b49 --- services/history-v1/buildscript.txt | 2 +- .../config/custom-environment-variables.json | 9 ++++++++- services/history-v1/docker-compose.ci.yml | 12 ++++++++++++ services/history-v1/docker-compose.yml | 12 ++++++++++++ services/history-v1/storage/scripts/redis.mjs | 16 ++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 services/history-v1/storage/scripts/redis.mjs diff --git a/services/history-v1/buildscript.txt b/services/history-v1/buildscript.txt index 4e1941660f..3b1c7d83de 100644 --- a/services/history-v1/buildscript.txt +++ b/services/history-v1/buildscript.txt @@ -1,5 +1,5 @@ history-v1 ---dependencies=postgres,gcs,mongo,s3 +--dependencies=postgres,gcs,mongo,redis,s3 --docker-repos=us-east1-docker.pkg.dev/overleaf-ops/ol-docker --env-add= --env-pass-through= diff --git a/services/history-v1/config/custom-environment-variables.json b/services/history-v1/config/custom-environment-variables.json index fc79743354..f9263ce1d2 100644 --- a/services/history-v1/config/custom-environment-variables.json +++ b/services/history-v1/config/custom-environment-variables.json @@ -82,5 +82,12 @@ "clusterWorkers": "CLUSTER_WORKERS", "maxFileUploadSize": "MAX_FILE_UPLOAD_SIZE", "httpsOnly": "HTTPS_ONLY", - "httpRequestTimeout": "HTTP_REQUEST_TIMEOUT" + "httpRequestTimeout": "HTTP_REQUEST_TIMEOUT", + "redis": { + "queue": { + "host": "REDIS_HOST", + "password": "REDIS_PASSWORD", + "port": "REDIS_PORT" + } + } } diff --git a/services/history-v1/docker-compose.ci.yml b/services/history-v1/docker-compose.ci.yml index 576f598b11..35c40bb7bb 100644 --- a/services/history-v1/docker-compose.ci.yml +++ b/services/history-v1/docker-compose.ci.yml @@ -19,6 +19,9 @@ services: image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER environment: ELASTIC_SEARCH_DSN: es:9200 + REDIS_HOST: redis + QUEUES_REDIS_HOST: redis + ANALYTICS_QUEUES_REDIS_HOST: redis MONGO_HOST: mongo POSTGRES_HOST: postgres AWS_S3_ENDPOINT: https://minio:9000 @@ -38,6 +41,8 @@ services: depends_on: mongo: condition: service_healthy + redis: + condition: service_healthy postgres: condition: service_healthy certs: @@ -59,6 +64,13 @@ services: - ./:/tmp/build/ command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs . user: root + redis: + image: redis + healthcheck: + test: ping="$$(redis-cli ping)" && [ "$$ping" = 'PONG' ] + interval: 1s + retries: 20 + mongo: image: mongo:6.0.13 command: --replSet overleaf diff --git a/services/history-v1/docker-compose.yml b/services/history-v1/docker-compose.yml index 5eff7b90c1..17dad0cb99 100644 --- a/services/history-v1/docker-compose.yml +++ b/services/history-v1/docker-compose.yml @@ -36,6 +36,9 @@ services: working_dir: /overleaf/services/history-v1 environment: ELASTIC_SEARCH_DSN: es:9200 + REDIS_HOST: redis + QUEUES_REDIS_HOST: redis + ANALYTICS_QUEUES_REDIS_HOST: redis MONGO_HOST: mongo POSTGRES_HOST: postgres AWS_S3_ENDPOINT: https://minio:9000 @@ -55,6 +58,8 @@ services: depends_on: mongo: condition: service_healthy + redis: + condition: service_healthy postgres: condition: service_healthy certs: @@ -67,6 +72,13 @@ services: condition: service_healthy command: npm run --silent test:acceptance + redis: + image: redis + healthcheck: + test: ping=$$(redis-cli ping) && [ "$$ping" = 'PONG' ] + interval: 1s + retries: 20 + mongo: image: mongo:6.0.13 command: --replSet overleaf diff --git a/services/history-v1/storage/scripts/redis.mjs b/services/history-v1/storage/scripts/redis.mjs new file mode 100644 index 0000000000..23f0b9b250 --- /dev/null +++ b/services/history-v1/storage/scripts/redis.mjs @@ -0,0 +1,16 @@ +import redis from '@overleaf/redis-wrapper' +import config from 'config' + +const redisOptions = config.get('redis.queue') + +console.log('REDIS CONFIG', redisOptions) +const rclient = redis.createClient(redisOptions) + +try { + await rclient.healthCheck() + console.log('REDIS HEALTHCHECK SUCCEEDED') +} catch (error) { + console.error('REDIS HEALTHCHECK FAILED', error) +} finally { + await rclient.quit() +}