我是Node.js的新手,希望使用流程运行程序.对于其他程序,我不得不同时启动一个服务器(mongodb,redis等),但我不知道我是否应该用这个运行一个.请让我知道我哪里出错了,以及如何纠正这个问题.提前致谢.
这是该计划:
var http = require('http'),
feed = 'http://isaacs.iriscouch.com/registry/_changes?feed=continuous';
function decide(cb) {
setTimeout(function () {
if (Date.now()%2) { return console.log('rejected'); }
cb();
}, 2000);
}
http.get(feed, function (res) {
decide(res.pipe.bind(res, process.stdout));
//using anonymous function instead of bind:
// decide(function () {
// res.pipe(process.stdout)
// });
});
Run Code Online (Sandbox Code Playgroud)
这是cmd输出:
<b>C:\05-Employing Streams\05-Employing Streams\23-Playing with pipes>node npm_stre
am_piper.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1583:20)
at TCP.onread (net.js:527:27)
</b>
Run Code Online (Sandbox Code Playgroud)
Gan*_*dey 88
关闭nodejs app
在另一个shell中运行.
重新启动终端并再次运行程序.
另一台服务器可能也使用了您用于nodejs的相同端口.杀死正在使用的进程nodejs port
并运行应用程序.
要查找使用port:8000的应用程序的PID
$ fuser 8000/tcp
8000/tcp: 16708
Run Code Online (Sandbox Code Playgroud)
这里PID是16708现在使用kill [PID]
命令终止进程
$ kill 16708
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
95043 次 |
最近记录: |