38 lines
904 B
JavaScript
Raw Normal View History

'use strict';
2018-09-12 22:21:26 -05:00
// Public node modules
const rimraf = require('rimraf');
// Logger.
2021-04-29 13:51:12 +02:00
const logger = require('@strapi/utils').logger;
module.exports = (scope, success, error) => {
const Redis = require(`ioredis`);
const redis = new Redis({
port: scope.database.settings.port,
host: scope.database.settings.host,
2018-01-17 10:13:23 +01:00
password: scope.database.settings.password,
2021-04-29 13:51:12 +02:00
db: scope.database.settings.database,
});
2021-04-29 13:51:12 +02:00
redis.connect(err => {
redis.disconnect();
if (err) {
2018-01-10 18:08:43 +01:00
logger.warn('Database connection has failed! Make sure your database is running.');
return error();
}
2018-01-10 18:08:43 +01:00
logger.info('The app has been connected to the database successfully!');
2021-04-29 13:51:12 +02:00
rimraf(scope.tmpPath, err => {
if (err) {
console.log(`Error removing connection test folder: ${scope.tmpPath}`);
}
logger.info('Copying the dashboard...');
success();
});
});
};