Node.js pm2——忽略手表不工作

Node.js pm2——忽略手表不工作,node.js,express,pm2,Node.js,Express,Pm2,我使用pm2已经有一段时间了。最近,我需要在我的Express4项目中添加一个名为“actionLog”的自定义日志目录。因为它是一个用日志文件更新的目录,我不希望pm2在日志文件更改时重新启动应用程序,所以我希望pm2忽略对该目录的监视。将pm2更新为最新版本后,我使用了以下命令: pm2 start app.js --watch --ignore-watch="actionLog" 我在pm2日志中发现以下错误: PM2 Error: watch ENOSPC PM2 at exp

我使用pm2已经有一段时间了。最近,我需要在我的Express4项目中添加一个名为“actionLog”的自定义日志目录。因为它是一个用日志文件更新的目录,我不希望pm2在日志文件更改时重新启动应用程序,所以我希望pm2忽略对该目录的监视。将pm2更新为最新版本后,我使用了以下命令:

pm2 start app.js --watch --ignore-watch="actionLog"
我在pm2日志中发现以下错误:

PM2 Error: watch ENOSPC
PM2     at exports._errnoException (util.js:746:11)
PM2     at FSWatcher.start (fs.js:1172:11)
PM2     at Object.fs.watch (fs.js:1198:11)
PM2     at createFsWatchInstance (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:37:15)
PM2     at setFsWatchListener (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:80:15)
PM2     at EventEmitter.NodeFsHandler._watchWithNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:228:14)
PM2     at EventEmitter.NodeFsHandler._handleFile (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:255:21)
PM2     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:468:21)
PM2     at FSReqWrap.oncomplete (fs.js:95:15)
PM2 Error: watch ENOSPC
PM2     at exports._errnoException (util.js:746:11)
PM2     at FSWatcher.start (fs.js:1172:11)
PM2     at Object.fs.watch (fs.js:1198:11)
PM2     at createFsWatchInstance (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:37:15)
PM2     at setFsWatchListener (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:80:15)
PM2     at EventEmitter.NodeFsHandler._watchWithNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:228:14)
PM2     at EventEmitter.NodeFsHandler._handleFile (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:255:21)
PM2     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:468:21)
PM2     at FSReqWrap.oncomplete (fs.js:95:15)
PM2 Error: watch ENOSPC
这也产生了同样的错误

一旦获得了正确的ignorewatch参数,我将更新用于启动pm2的json配置文件。目前,将此配置文件与ignore watch一起使用也会导致错误,但我在pm2日志中只看到以下内容,而不是上面所述的详细堆栈跟踪:

PM2: 2016-02-23 04:05:34: Starting execution sequence in -fork mode- for app name:aadm id:2
PM2: 2016-02-23 04:05:34: App name:aadm id:2 online
PM2: 2016-02-23 04:05:35: Change detected on path actionLog/userAction.log for app aadm - restarting
PM2: 2016-02-23 04:05:35: Stopping app:aadm id:2
PM2: 2016-02-23 04:05:35: App name:aadm id:2 exited with code SIGTERM
PM2: 2016-02-23 04:05:35: Process with pid 5102 killed
PM2: 2016-02-23 04:05:35: Starting execution sequence in -fork mode- for app name:aadm id:2
PM2: 2016-02-23 04:05:35: App name:aadm id:2 online
我已经看过一些关于忽略观察问题的报告,例如:


不幸的是,我仍然被卡住了。有什么想法吗?

我认为这是
忽略手表
即带有下划线

结果表明,即使错误是由忽略手表触发的,它们也不是由它引起的。以下命令修复了该问题:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
我在这里找到了这个解决方案:

我还尝试了“npm重复数据消除”——正如在该线程上建议的那样——但没有任何帮助

您有两个选择:

  • 增加系统inotify最大监视限制:
    echo fs.inotify.max_user_watches=524288 | sudo tee-a/etc/sysctl.conf&&sudo sysctl-p
  • 尝试通过另外忽略
    节点模块来减少您的观看次数。

    pm2启动箱/www--watch--ignore watch=“actionLog node\u模块”

  • 如果您没有sudo权限,则选项2适用于您。

    命令行参数为--ignore watch。请参阅:。如果在配置文件中使用它,则会使用ignore\u watch。有关详情,请参阅:
    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p