1

尝试使用 pm2 启动和运行 nodejs 应用程序。

我们使用 SASS 并使用“node-sass-middleware”在文件更改时重建到 css 文件。一切正常,直到 pm2 每次 sass 中间件重建一个 css 文件时自动重启应用程序......这就是我们告诉它要做的事情:

pm2 start app.js --watch 因此,在阅读了一些文档之后,您似乎应该能够使用 json 文件配置 pm2,并且它具有“ignore_watch”选项。

因此,按照 github 上的指南:https ://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#json-app-declaration我们设置了一个配置 json 文件,如下所示:

{
    "name"        : "ourApp",
    "script"      : "server.js",
    "watch"       : true,
    "ignore_watch" : ["public/css"],
    "env": {
        "NODE_ENV": "development"
    }
}

问题是,一旦我们尝试运行它,pm2 日志就会吐出 1000 行日志错误,看起来都像这样:

PM2: 2015-05-09 15:32:00: Error: watch ENOSPC
PM2:     at errnoException (fs.js:1024:11)
PM2:     at FSWatcher.start (fs.js:1056:11)
PM2:     at Object.fs.watch (fs.js:1081:11)
PM2:     at createFsWatchInstance (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:24:15)
PM2:     at setFsWatchListener (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:47:19)
PM2:     at EventEmitter.NodeFsHandler._watchWithNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:177:15)
PM2:     at EventEmitter.NodeFsHandler._handleFile (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:201:8)
PM2:     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:353:12)
PM2:     at Object.oncomplete (fs.js:107:15)
PM2: 2015-05-09 15:32:00: Error: watch ENOSPC
PM2:     at errnoException (fs.js:1024:11)
PM2:     at FSWatcher.start (fs.js:1056:11)
PM2:     at Object.fs.watch (fs.js:1081:11)
PM2:     at createFsWatchInstance (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:24:15)
PM2:     at setFsWatchListener (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:47:19)
PM2:     at EventEmitter.NodeFsHandler._watchWithNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:177:15)
PM2:     at EventEmitter.NodeFsHandler._handleFile (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:201:8)
PM2:     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:353:12)
PM2:     at Object.oncomplete (fs.js:107:15)
PM2: 2015-05-09 15:32:00: Process with pid 9155 still not killed, retrying...
PM2: 2015-05-09 15:32:00: Process with pid 9155 still alive after 800ms

感谢下面的答案 这似乎是罪魁祸首,显然在 linux 世界中 ENOSPC 意味着没有剩余磁盘空间.. 但是整个开发服务器上仅使用 2.1gig,总 HDD 空间为 25gig,这不是问题。

PM2:2015-05-09 15:32:00:错误:观看 ENOSPC

此外,当我们从顶部提到的 cli 运行 pm2 时,一切都很完美......

我们真的需要这样做,因为它对开发团队造成了严重破坏。

有没有其他人遇到过这个问题?

谢谢,约翰

4

1 回答 1

0

ENOSPC表示设备上没有剩余空间。因此,请检查您的某个文件系统是否已满。假设您在 Linux 或其他类 Unix 操作系统上,/tmp并且/var可能是候选人。

于 2015-05-09T15:57:02.107 回答