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.

23 lines
557 B

  1. const Redis = require('ioredis')
  2. const { isPlainObject } = require('lodash')
  3. /* global WIKI */
  4. module.exports = {
  5. init() {
  6. if (isPlainObject(WIKI.config.redis)) {
  7. let red = new Redis(WIKI.config.redis)
  8. red.on('ready', () => {
  9. WIKI.logger.info('Redis connection: [ OK ]')
  10. })
  11. red.on('error', () => {
  12. WIKI.logger.error('Failed to connect to Redis instance!')
  13. process.exit(1)
  14. })
  15. return red
  16. } else {
  17. WIKI.logger.error('Invalid Redis configuration!')
  18. process.exit(1)
  19. }
  20. }
  21. }