Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
hotfix - redis error in deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianjost committed Mar 9, 2020
1 parent c86122a commit b38e925
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
35 changes: 18 additions & 17 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 6 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ services:
- data-editor-mongodb:/data/db
restart: unless-stopped

redis:
image: redis:5.0.3

schulcloud-editor:
build:
context: ../
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/middleware/feathersSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ const sync = require('feathers-sync');
module.exports = (app) => {
app.configure(sync({
uri: app.get('redis'),
key: app.get('redis_key'),
}));
};
8 changes: 6 additions & 2 deletions src/middleware/index.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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.');
Expand Down

0 comments on commit b38e925

Please sign in to comment.