Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的 node.js 应用程序中使用Forever 。我正在启动一个子进程,例如:
var forever = require('forever'); child = new (forever.Monitor)('path/to/my/server.js', { max: 3, silent: true, options: [] }); child.start();
我怎样才能找出那个子进程的pid?
var forever = require('forever'); child = new (forever.Monitor)('path/to/my/server.js', { max: 3, silent: true, options: [] }); child.on('start', function(process, data) { console.log(data.pid); }); child.start();
监听 'start' 事件,它是传递给回调函数的第二个参数的 pid 属性。