PM2抛出错误w / Express app端口侦听器和phantomjs-node实例

时间:2015-05-28 00:19:56

标签: node.js express phantomjs pm2

所以我有一个正在监听localhost:8888的快速应用程序,如果我在节点中独立运行它,它听起来很好。但是当我尝试使用PM2运行它时,我在PM2日志中得到了以下错误。

var
    phantom = require('phantom'),
    express = require('express'),
    serve = express();

phantom.create(function(ph) {
    console.log('Phantom browser created.');
    serve.get('/foo', function (req, res) {
        res.json({foo: 'bar'});
        res.end();
    });

    serve.listen(8888);
});

pm2 start -i 0 myserver.js

PM2显示它启动了8个进程但是如果我pm2 list则没有任何进程。

查看pm2 logs我在下面的日志中看到错误。但是..如果我注释掉serve.listen(8888);行,它就可以正常工作。我在世界上做错了什么?

PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:0
PM2: 2015-05-27 17:16:14: App name:myserver id:0 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:1
PM2: 2015-05-27 17:16:14: App name:myserver id:1 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:2
PM2: 2015-05-27 17:16:14: App name:myserver id:2 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:3
PM2: 2015-05-27 17:16:14: App name:myserver id:3 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:4
PM2: 2015-05-27 17:16:14: App name:myserver id:4 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:5
PM2: 2015-05-27 17:16:14: App name:myserver id:5 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:6
PM2: 2015-05-27 17:16:14: App name:myserver id:6 online
PM2: 2015-05-27 17:16:14: Starting execution sequence in -cluster mode- for app name:myserver id:7
PM2: 2015-05-27 17:16:15: App name:myserver id:7 online
myserver-1 (out): Phantom broswer created.
myserver-3 (out): Phantom broswer created.
myserver-5 (out): Phantom broswer created.
myserver-1 (out): Phantom broswer created.
PM2: 2015-05-27 17:16:17: [PM2] Error caught by domain:
PM2: AssertionError: false == true
PM2:     at RoundRobinHandle.add (cluster.js:140:3)
PM2:     at queryServer (cluster.js:480:12)
PM2:     at Worker.onmessage (cluster.js:438:7)
PM2:     at ChildProcess.<anonymous> (cluster.js:692:8)
PM2:     at ChildProcess.emit (events.js:129:20)
PM2:     at handleMessage (child_process.js:324:10)
PM2:     at Pipe.channel.onread (child_process.js:352:11)
myserver-7 (out): Phantom broswer created.
myserver-3 (out): Phantom broswer created.
PM2: 2015-05-27 17:16:17: [PM2] Automatic `pm2 update` failed. Killing PM2 daemon and its processes...
PM2: 2015-05-27 17:16:17: pm2 has been killed by signal, dumping process list before exit...
PM2: 2015-05-27 17:16:17: Stopping app:myserver id:0
PM2: 2015-05-27 17:16:17: App name:myserver id:0 disconnected
myserver-5 (out): Phantom broswer created.
PM2: assert.js:86
PM2:   throw new assert.AssertionError({
PM2:         ^
PM2: AssertionError: false == true
PM2:     at RoundRobinHandle.add (cluster.js:140:3)
PM2:     at queryServer (cluster.js:480:12)
PM2:     at Worker.onmessage (cluster.js:438:7)
PM2:     at ChildProcess.<anonymous> (cluster.js:692:8)
PM2:     at ChildProcess.emit (events.js:129:20)
PM2:     at handleMessage (child_process.js:324:10)
PM2:     at Pipe.channel.onread (child_process.js:352:11)
myserver-0 (err): Process disconnected from parent !
PM2: [PM2] Spawning PM2 daemon
PM2: 2015-05-27 17:16:18: [PM2][WORKER] Started with refreshing interval: 30000
PM2: 2015-05-27 17:16:18: [[[[ PM2/God daemon launched ]]]]
PM2: 2015-05-27 17:16:18: BUS system [READY] on port /Users/matthewmarcus/.pm2/pub.sock
PM2: 2015-05-27 17:16:18: RPC interface [READY] on port /Users/matthewmarcus/.pm2/rpc.sock
PM2: [PM2] PM2 Successfully daemonized
PM2: Be sure to have the latest version by doing `npm install pm2@latest -g` before doing this procedure.
PM2: [PM2] Stopping PM2...
PM2: [PM2][WARN] No process found
PM2: [PM2] All processes have been stopped and deleted
PM2: 2015-05-27 17:16:18: PM2 is being killed via kill method
PM2: 2015-05-27 17:16:18: RPC socket closed
PM2: 2015-05-27 17:16:18: PUB socket closed
PM2: [PM2] PM2 stopped
PM2: 2015-05-27 17:16:19: [PM2][WORKER] Started with refreshing interval: 30000
PM2: 2015-05-27 17:16:19: [[[[ PM2/God daemon launched ]]]]
PM2: 2015-05-27 17:16:19: BUS system [READY] on port /Users/matthewmarcus/.pm2/pub.sock
PM2: 2015-05-27 17:16:19: RPC interface [READY] on port /Users/matthewmarcus/.pm2/rpc.sock
PM2: >>>>>>>>>> PM2 updated
PM2: ┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬────────┬──────────┐
PM2: │ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
PM2: └──────────┴────┴──────┴─────┴────────┴─────────┴────────┴────────┴──────────┘
PM2:  Use `pm2 show <id|name>` to get more details about an app

0 个答案:

没有答案