diff --git a/config/default.json b/config/default.json index 4d82d55..b39b9f8 100644 --- a/config/default.json +++ b/config/default.json @@ -1,17 +1,18 @@ -{ - "host": "localhost", - "port": 4001, - "protocol": "http", - "mongodb": "mongodb://localhost:27017/schulcloud-editor", - "routes": { - "server": { - "baseURL": "http://localhost:3030", - "coursePermissionsUri": "/courses/:courseId/userPermissions", - "meUri": "/me", - "courseMembersUri": "/courses/:courseId/members" - }, - "timeout": "30000" - }, - "testsecret": "secret", - "redis": "REDIS_URI" -} +{ + "host": "localhost", + "port": 4001, + "protocol": "http", + "mongodb": "mongodb://localhost:27017/schulcloud-editor", + "routes": { + "server": { + "baseURL": "http://localhost:3030", + "coursePermissionsUri": "/courses/:courseId/userPermissions", + "meUri": "/me", + "courseMembersUri": "/courses/:courseId/members" + }, + "timeout": "30000" + }, + "testsecret": "secret", + "redis": "REDIS_URI", + "redis_key": "REDIS_KEY" +} diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index d7ba1a0..cb8619f 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -15,6 +15,9 @@ services: - data-editor-mongodb:/data/db restart: unless-stopped + redis: + image: redis:5.0.3 + schulcloud-editor: build: context: ../ @@ -25,11 +28,13 @@ services: - PORT=4101 - SERVER_API_URL=http://server:3030 - TIMEOUT=30000 - - REDIS_URI="redis://redis:6379/schulcloud-editor" + - REDIS_URI=redis://redis:6379 + - REDIS_KEY=schulcloud-editor-sync ports: - 4101:4101 depends_on: - editor-mongodb + - redis restart: unless-stopped volumes: diff --git a/src/middleware/feathersSync.js b/src/middleware/feathersSync.js index 9453085..e921a27 100644 --- a/src/middleware/feathersSync.js +++ b/src/middleware/feathersSync.js @@ -3,5 +3,6 @@ const sync = require('feathers-sync'); module.exports = (app) => { app.configure(sync({ uri: app.get('redis'), + key: app.get('redis_key'), })); }; diff --git a/src/middleware/index.js b/src/middleware/index.js index 6179f29..fbfcb36 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -const { systemInfo } = require('../logger'); +const { systemInfo, logger } = require('../logger'); const addLoggerToApp = require('./addLoggerToApp'); const requestLogs = require('./requestLogs'); const ping = require('./ping'); @@ -31,8 +31,12 @@ module.exports = function setup(app) { } exec(aggregateAppVars, 'aggregateAppVars: Add aggregate app vars and display it.'); // TODO: no middleware exec(socket, 'socket: Add socket connections'); - if (app.get('redis') && app.get('redis') !== 'REDIS_URI') { + const redisUriDefined = app.get('redis') && app.get('redis') !== 'REDIS_URI'; + const redisKeyDefined = app.get('redis_key') && app.get('redis_key') !== 'REDIS_KEY'; + if (redisUriDefined && redisKeyDefined) { exec(feathersSync, 'feathers-sync: Add feathers-sync'); + } else { + logger.warning(`REDIS_URI (${app.get('redis')}) or REDIS_KEY (${app.get('redis_key')}) env is not defined`); } if (app.get('NODE_ENV') !== 'test') { exec(sentry, 'sentry: Add sentry for logging errors.');