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. }