mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
557 B
24 lines
557 B
8 years ago
|
const Redis = require('ioredis')
|
||
|
const { isPlainObject } = require('lodash')
|
||
|
|
||
7 years ago
|
/* global wiki */
|
||
8 years ago
|
|
||
7 years ago
|
module.exports = {
|
||
8 years ago
|
init() {
|
||
|
if (isPlainObject(wiki.config.redis)) {
|
||
8 years ago
|
let red = new Redis(wiki.config.redis)
|
||
|
red.on('ready', () => {
|
||
7 years ago
|
wiki.logger.info('Redis connection: [ OK ]')
|
||
8 years ago
|
})
|
||
7 years ago
|
red.on('error', () => {
|
||
|
wiki.logger.error('Failed to connect to Redis instance!')
|
||
|
process.exit(1)
|
||
|
})
|
||
8 years ago
|
return red
|
||
8 years ago
|
} else {
|
||
|
wiki.logger.error('Invalid Redis configuration!')
|
||
|
process.exit(1)
|
||
|
}
|
||
|
}
|
||
|
}
|