"s": {
"start": "node --inspect=0.0.0.0:9229 server/app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/triestpa/guttenberg-search.git"
},
"author": "patrick.triest@gmail.com",
"license": "MIT",
"bugs": {
"url": "https://github.com/triestpa/guttenberg-search/issues"
},
"homepage": "https://github.com/triestpa/guttenberg-search#readme",
"dependencies": {
"elasticsearch": "13.3.1",
"joi": "13.0.1",
"koa": "2.4.1",
"koa-joi-validate": "0.5.1",
"koa-router": "7.2.1"
}
}
此文件定义应用开始命令和Node.js依赖包。
注意:不需要特意运行npm install,容器创建时候会自动安装依赖包。
2.6 开始测试
都准备好了,接下来可以测试了。从项目根目录开始,运行docker-compose,会自动创建Node.js容器应用。

运行docker-compose up启动应用:

注意:这一步可能会运行时间比较长,因为Docker可能需要下载基础镜像。以后执行速度会很快,因为本地已经有了基础镜像。
访问localhost:8080,应该看到如下图输出“hello world”。

访问localhost:3000验证服务器端返回“hello world”信息。

最后,访问localhost:9200确认Elasticsearch是否运行,如果正常,应该返回如下输出:
{
"name": "SLTcfpI",
"cluster_name": "docker-cluster",
"cluster_uuid": "iId8e0ZeS_mgh9ALlWQ7-w",
"version": {
"number": "6.1.1",
"build_hash": "bd92e7f",
"build_date": "2017-12-17T20:23:25.338Z",
"build_snapshot": false,
"lucene_version": "7.1.0",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}
如果所有URL输出都正常,恭喜,整个应用框架可以正常工作,下面开始进入真正有趣的部分了。
3. 接入Elasticsearch
第一步是要接入本地Elasticsearch实例。
3.0 加入ES链接模块
在server/connection.js中加入如下初始化代码:
constelasticsearch = require( 'elasticsearch')
// Core ES variables for this project
constindex = 'library'
consttype = 'novel'
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-88488-4.html
面对赤裸裸的挑衅
如不醒悟
全天然啊