据我所知,我已按照 api 文档中的说明进行操作。我使用选项生成进程,detached:true, stdio:['ignore','ignore','ignore']调用unrefChildProcess。ChildProcess 有一个pid,所以我认为它已成功启动。我正在尝试从 grunt 任务中启动 Yeti 服务器。此代码在异步调用中,因此next继续并最终完成任务。我which用来获取cmd,它是/usr/local/binMac OSX 10.9 上的 Yeti 脚本的正确路径。端口也定义为空端口。如果我在命令行上运行相同的命令,它就可以正常工作。在 grunt 退出后,我为记录的 pid 调用ps aux | grep node和ps auxgrep 并且没有任何运行。这是代码:
yeti = spawn("" + cmd + " --server --port " + port, [], {
detached: true,
stdio: ['ignore', 'ignore', 'ignore']
});
yeti.unref();
next("Yeti server is running. pid: " + yeti.pid);