mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 07:33:17 +00:00
Process exit when Redis connection failed
This commit is contained in:
parent
eade0d37c7
commit
0a2db78275
@ -90,7 +90,7 @@ module.exports = function (strapi) {
|
||||
// Return callback if there is no model
|
||||
if (_.isEmpty(models)) {
|
||||
cb();
|
||||
|
||||
|
||||
// Break the loop.
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ const Redis = require('ioredis');
|
||||
* Redis hook
|
||||
*/
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = function (strapi) {
|
||||
const hook = {
|
||||
|
||||
/**
|
||||
@ -26,7 +26,8 @@ module.exports = function () {
|
||||
port: 6379,
|
||||
host: 'localhost',
|
||||
family: 4,
|
||||
db: 0
|
||||
db: 0,
|
||||
showFriendlyErrorStack: (process.env.NODE_ENV !== 'production')
|
||||
},
|
||||
|
||||
/**
|
||||
@ -49,9 +50,9 @@ module.exports = function () {
|
||||
const redis = new Redis(connection.settings);
|
||||
|
||||
redis.on('error', (err) => {
|
||||
cb(err);
|
||||
|
||||
return process.kill();
|
||||
strapi.log.error(err);
|
||||
process.exit(0);
|
||||
return;
|
||||
});
|
||||
|
||||
// Utils function.
|
||||
@ -93,7 +94,9 @@ module.exports = function () {
|
||||
});
|
||||
}
|
||||
|
||||
done();
|
||||
redis.on('ready', () => {
|
||||
done();
|
||||
});
|
||||
} catch (e) {
|
||||
cb(e);
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ module.exports = function () {
|
||||
watch: true,
|
||||
watchDirectory: process.cwd(),
|
||||
watchIgnoreDotFiles: true, // Whether to ignore file starting with a '.'
|
||||
watchIgnorePatterns: ['node_modules/**/*', 'public/**/*'], // Ignore patterns to use when watching files.
|
||||
watchIgnorePatterns: ['node_modules/**/*', 'public/**/*', '.git/**/*', '.idea'], // Ignore patterns to use when watching files.
|
||||
killTree: true, // Kills the entire child process tree on `exit`,
|
||||
spinSleepTime: 0,
|
||||
command: 'node --harmony-async-await'
|
||||
@ -52,9 +52,15 @@ module.exports = function () {
|
||||
const child = new (forever.Monitor)('server.js', options);
|
||||
|
||||
// Run listeners
|
||||
child.on('restart', () => {
|
||||
child.on('watch:restart', (info) => {
|
||||
console.log();
|
||||
logger.info('Restarting due to changes...');
|
||||
logger.verbose('Restarting due to ' + info.file + '... (' + info.stat.replace(child.cwd, '.') + ')');
|
||||
console.log();
|
||||
});
|
||||
|
||||
child.on('exit:code', function(code) {
|
||||
console.log();
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
// Start child process
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user