-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BC-8621 call sync legacy indexes via rest
- Loading branch information
Showing
10 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ansible/roles/schulcloud-server-init/templates/management-configmap.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: api-management-configmap | ||
namespace: {{ NAMESPACE }} | ||
labels: | ||
app: management-deployment | ||
data: | ||
NEST_LOG_LEVEL: "{{ NEST_LOG_LEVEL }}" | ||
EXIT_ON_ERROR: "true" | ||
ENABLE_SYNC_LEGACY_INDEXES_VIA_FEATHERS_SERVICE: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const mongoose = require('mongoose'); | ||
const { Configuration } = require('@hpi-schul-cloud/commons'); | ||
const logger = require('../../logger'); | ||
|
||
const getModels = () => Object.entries(mongoose.models); | ||
|
||
class Service { | ||
constructor(options) { | ||
this.options = options || {}; | ||
this.docs = {}; | ||
} | ||
|
||
async create(data, params) { | ||
if (Configuration.get('ENABLE_SYNC_LEGACY_INDEXES_VIA_FEATHERS_SERVICE')) { | ||
const models = getModels(); | ||
for (const [modelName, model] of models) { | ||
logger.alert(`${modelName}.syncIndexes()`); | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
await model.syncIndexes(); | ||
} catch (err) { | ||
logger.alert(err); | ||
} | ||
} | ||
} else { | ||
logger.alert( | ||
'sync-legacy-indexes has been called without enabling ENABLE_SYNC_LEGACY_INDEXES_VIA_FEATHERS_SERVICE' | ||
); | ||
} | ||
} | ||
|
||
setup(app) { | ||
this.app = app; | ||
} | ||
} | ||
|
||
module.exports = function () { | ||
const app = this; | ||
|
||
app.use('/sync-legacy-indexes', new Service()); | ||
}; | ||
|
||
module.exports.Service = Service; |