• Hexo集成Algolia搜索插件时遇到的问题


    从来就没有什么救世主

    今天刚刚写了一篇随笔,发布之后,发现在github.com 上并没有部署成功,
    于是就到travis-ci.org 上查找了,发现CI 自动部署失败。
    在CI 的log 中查找的原因,费了九牛二虎之力才修复成功。
    而这篇文章就是记录自己的解决过程。

    问题描述

    travis-ci.org 部署日志中发现了如下错误

    hexo algolia
    INFO  [hexo-algolia] Testing HEXO_ALGOLIA_INDEXING_KEY permissions.
    ERROR [hexo-algolia] getaddrinfo ENOTFOUND sv57wj53os-1.algolianet.com
    ERROR >> You might have used an Admin Key or an invalid Key.
    ERROR >> Read https://npmjs.com/hexo-algolia#security-concerns for more informations.
    The command "hexo algolia" exited with 1.
    

    问题分析

    1.主要是分析

    getaddrinfo ENOTFOUND sv57wj53os-1.algolianet.com
    

    应该是sv57wj53os-1.algolianet.com域名解析失败,将此地址放到浏览器访问中提示如下

    2.在hexo-algolia 的源码上 https://github.com/oncletom/hexo-algolia/blob/master/lib/command.js#L77 找到如下代码

    hexo.log.info('[hexo-algolia] Testing HEXO_ALGOLIA_INDEXING_KEY permissions.');
    
    return client.getApiKey(apiKey)
    .catch(function(err){
        hexo.log.error('[hexo-algolia] %s', err.message);
        hexo.log.error('>> You might have used an Admin Key or an invalid Key.');
        hexo.log.error('>> Read %s for more informations.', 'https://npmjs.com/hexo-algolia#security-concerns');
        process.exit(1);
    });
    })
    

    3.是在获取client.ApiKey() 时,遇到的问题,而client 是由

    var algoliasearch = require('algoliasearch');
    var client;
    client = algoliasearch(applicationID, apiKey);
    

    赋值的。

    4.需要到algoliasearch 的源码上查找,而algoliasearch 是在http://theme-next.iissnan.com/third-party-services.html#algolia-search 第三方服务Aloglia 中实现的。在https://github.com/iissnan/hexo-theme-next/blob/master/source/lib/algolia-instant-search/instantsearch.min.js 搜素algolianet.com 结果如下:

    5.也就是说sv57wj53os-1.algolianet.com 是由applicationIDaligolianet.com 组成。

    6.在_config.yml 中设置的applicationIDJQFAQAQAP5

    # Algolia
    algolia:
      applicationID: 'JQFAQAQAP5'
      indexName: 'dev_jobbymsblog'
      chunkSize: 5000
    

    7.重新提交代码,再次执行就OK 了

    解决方案

    1.重新提交代码,再次执行,发现执行成功了

    $ hexo algolia
    INFO  [hexo-algolia] Testing HEXO_ALGOLIA_INDEXING_KEY permissions.
    INFO  Start processing
    INFO  [hexo-algolia] 196 records to index (post, page).
    INFO  [hexo-algolia] Indexing chunk 1 of 4 (50 records)
    INFO  [hexo-algolia] Indexing chunk 2 of 4 (50 records)
    INFO  [hexo-algolia] Indexing chunk 3 of 4 (50 records)
    INFO  [hexo-algolia] Indexing chunk 4 of 4 (46 records)
    INFO  [hexo-algolia] Indexing done.
    The command "hexo algolia" exited with 0.
    
  • 相关阅读:
    【codevs1002】搭桥(prim)
    【codevs1993】草地排水(最大流)
    NOIP总结
    【codevs1069】关押罪犯[noip2010](并查集)
    第一章 数据库的设计
    Socket与ServerSocket
    关于 httpUrlConnection 的 setDoOutput 与 setDoInput的区别
    java基础复习1
    eclipes快捷键
    List Set Map 的区别 用法以及特点(转载)
  • 原文地址:https://www.cnblogs.com/JobbyM/p/14080852.html
Copyright © 2020-2023  润新知