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
7 years ago
|
const Redis = require('ioredis')
|
||
|
const { isPlainObject } = require('lodash')
|
||
|
|
||
7 years ago
|
/* global wiki */
|
||
7 years ago
|
|
||
7 years ago
|
module.exports = {
|
||
7 years ago
|
init() {
|
||
|
if (isPlainObject(wiki.config.redis)) {
|
||
7 years ago
|
let red = new Redis(wiki.config.redis)
|
||
|
red.on('ready', () => {
|
||
7 years ago
|
wiki.logger.info('Redis connection: [ OK ]')
|
||
7 years ago
|
})
|
||
7 years ago
|
red.on('error', () => {
|
||
|
wiki.logger.error('Failed to connect to Redis instance!')
|
||
|
process.exit(1)
|
||
|
})
|
||
7 years ago
|
return red
|
||
7 years ago
|
} else {
|
||
|
wiki.logger.error('Invalid Redis configuration!')
|
||
|
process.exit(1)
|
||
|
}
|
||
|
}
|
||
|
}
|