composer-rest-server运行笔记
composer-rest-server有两种运行方式。
(1)交互式
http://www..com/article/7944230303/参见这边的第五步。这篇文章绝了。
https://my.oschina.net/u/3782027/blog/1841728这个也类似。很好的参照物。
记录一下我自己的参数,免得忘记了:
(2)命令行形式
没讲。
这个东西会启动一个explorer网页,可以进行一些CRUD operations。
哦豁,我的卡住不动了。
使用ctrl+z停止了该项任务。重新启动报错。
报错内容如下:
[email protected]-ThinkPad-E550:~/cprogrames/test-bna/dist$ composer-rest-server
? Enter the name of the business network card to use: [email protected]-bna
? Specify if you want namespaces in the generated REST API: always use namespaces
? Specify if you want to use an API key to secure the REST API: No
? Specify if you want to enable authentication for the REST API using Passport: No
? Specify if you want to enable the explorer test interface: No
? Specify a key if you want to enable dynamic logging: 1111
? Specify if you want to enable event publication over WebSockets: Yes
? Specify if you want to enable TLS security for the REST API: No
To restart the REST server using the same options, issue the following command:
composer-rest-server -c [email protected]-bna -n always -d 1111 -w true
Discovering types from business network definition ...
Discovering the Returning Transactions..
Discovered types from business network definition
Generating schemas for all types in business network definition ...
Generated schemas for all types in business network definition
Adding schemas for all types to Loopback ...
Added schemas for all types to Loopback
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at module.exports.promise.then.then (/home/cielo/.nvm/versions/node/v8.15.1/lib/node_modules/composer-rest-server/cli.js:143:19)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
嘻嘻,这个错误我熟悉,node没关闭。刚刚占了个3000端口吧。
执行:lsof -i
找到占用3000的编号:node 25116 cielo 30u IPv6 6921843 0t0 TCP *:3000 (LISTEN)
执行:sudo kill -9 25116
即可。
好了重新执行还是卡在那边。我等等他吧。
??????????难道我没有explorer??????????
这不可能。
我完成了npm install 也没有可以访问的东西。
所有端口都在这了,只有个3000还有个9328端口是可以访问的。这让人有些抑郁啊。9328端口是啥玩意???
这啥意思啊。
虽然不知道啥意思,但我已经进去explorer了。
具体问题以及解决方法见下面这个链接。
https://blog.csdn.net/qq_38904077/article/details/89196853
具体演示
照着****似乎不行,我自己摸索一下:
先建立一个participant
{
"$class": "test.SampleParticipant",
"participantId": "pID1",
"firstName": "Cielo",
"lastName": "Zou"
}
建立成功: