pm2 start index.js
pm2 start process.json
$ pm2 list
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤
│ index │ 0 │ fork │ 48337 │ online │ 0 │ 2m │ 23.746 MB │ disabled │
│ lianj-pc │ 1 │ fork │ 48871 │ online │ 1 │ 20s │ 74.781 MB │ disabled │
│ demo │ 2 │ fork │ 48889 │ online │ 1 │ 20s │ 64.785 MB │ disabled │
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘
其中 index 启动端口为 8001 ,其他两个分别为 9000 , 8000 。 ** index id=0, lianj-pc id=1, demo id=2 **
# 节选自 pm2.log
2016-07-08 16:10:24: Stopping app:lianj-pc id:1
2016-07-08 16:10:24: App [lianj-pc] with id [1] and pid [48454], exited with code [0] via signal [SIGINT]
2016-07-08 16:10:24: Starting execution sequence in -fork mode- for app name:lianj-pc id:1
2016-07-08 16:10:24: ***App name:lianj-pc id:1 online***
2016-07-08 16:10:24: Stopping app:demo id:2
2016-07-08 16:10:24: App [demo] with id [2] and pid [48456], exited with code [0] via signal [SIGINT]
2016-07-08 16:10:24: Starting execution sequence in -fork mode- for app name:demo id:2
2016-07-08 16:10:24: ***App name:demo id:2 online***
2016-07-08 16:11:04: Stopping app:lianj-pc id:1
2016-07-08 16:11:04: App [lianj-pc] with id [1] and pid [48871], exited with code [0] via signal [SIGINT]
2016-07-08 16:11:05: Starting execution sequence in -fork mode- for app name:lianj-pc id:0
2016-07-08 16:11:05: ***App name:lianj-pc id:0 online***
2016-07-08 16:11:05: Stopping app:demo id:2
2016-07-08 16:11:05: App [demo] with id [2] and pid [48889], exited with code [0] via signal [SIGINT]
2016-07-08 16:11:05: Starting execution sequence in -fork mode- for app name:demo id:0
2016-07-08 16:11:05: ***App name:demo id:0 online***
2016-07-08 16:11:05: App [lianj-pc] with id [0] and pid [49126], exited with code [255] via signal [SIGINT]
2016-07-08 16:11:05: Starting execution sequence in -fork mode- for app name:demo id:0
2016-07-08 16:11:05: App name:demo id:0 online
2016-07-08 16:11:05: App [demo] with id [0] and pid [49144], exited with code [255] via signal [SIGINT]
2016-07-08 16:11:05: Starting execution sequence in -fork mode- for app name:demo id:0
2016-07-08 16:11:05: App name:demo id:0 online
2016-07-08 16:11:05: App [demo] with id [0] and pid [49158], exited with code [255] via signal [SIGINT]
2016-07-08 16:11:05: Starting execution sequence in -fork mode- for app name:demo id:0
2016-07-08 16:11:05: App name:demo id:0 online
2016-07-08 16:11:05: App [demo] with id [0] and pid [49183], exited with code [255] via signal [SIGINT]
2016-07-08 16:11:05: Starting execution sequence in -fork mode- for app name:demo id:0
2016-07-08 16:11:05: App name:demo id:0 online
2016-07-08 16:11:05: App [demo] with id [0] and pid [49188], exited with code [255] via signal [SIGINT]
"pm2.log" 11301L, 938877C
2016-07-08 16:22:21: App [lianj-pc] with id [0] and pid [17471], exited with code [255] via signal [SIGINT]
2016-07-08 16:22:21: Starting execution sequence in -fork mode- for app name:lianj-pc id:0
请看我在日志中加了***的部分,启动 id 和 app name 的对应已经发生混乱,都对应到了 index 的 id 上去,结果就是 index 不断重启,但是又因为重复绑定端口而报错,日志如下:
M2 App [lianj-pc] with id [0] and pid [66856], exited with code [255] via signal [SIGINT]
PM2 Starting execution sequence in -fork mode- for app name:lianj-pc id:0
PM2 App name:lianj-pc id:0 online
lianj-pc-0 Error: listen EADDRINUSE 127.0.0.1:8001
lianj-pc-0 at Object.exports._errnoException (util.js:870:11)
lianj-pc-0 at exports._exceptionWithHostPort (util.js:893:20)
lianj-pc-0 at Server._listen2 (net.js:1234:14)
lianj-pc-0 at listen (net.js:1270:10)
lianj-pc-0 at net.js:1379:9
lianj-pc-0 at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:64:16)
lianj-pc-0 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:83:10)
想从 Google 问个究竟,却始终查不出什么,不知道大家有没有遇到的,目前来看会不会就是不能混合使用启动方式呢?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.