我使用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我还尝试使用以下命令:
pm2 start bin/www --watch --ignore-watch="actionLog"这也会产生同样的错误。
一旦我有了正确的忽略-监视参数,我将更新用于启动pm2的json配置文件。目前,将这个配置文件与忽略监视一起使用也会导致错误,但是,我只在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我看过一些有关视而不见的问题的报道,例如:
不幸的是我还是被困住了。有什么想法吗?
发布于 2016-02-24 00:38:14
事实证明,即使这些错误是由忽略手表触发的,但它们并不是由它引起的。以下命令修复了这个问题:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p我在这里找到了这个解决方案:https://stackoverflow.com/a/32600959/2234029
我也尝试过"npm“-as在那条线上建议--但没有帮助。
发布于 2016-06-23 21:19:09
你有两个选择:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p或
node_modules**:** 试图通过另外忽略来减少观看次数
pm2 start bin/www --watch --ignore-watch="actionLog node_modules"如果您没有sudo的权利,选项2是为您。
发布于 2022-04-20 21:03:57
我也有同样的问题。这让我抓狂,然后我发现在我的系统中运行了许多PM2会话。像ps aux | grep pm2这样的命令显示正在运行的所有实例。
因此,我手动地杀死了每个实例(如上面的命令所示),一个接一个地使用:
kill -9 <pid1> <pid2> <pid3> <...>
最后,我重新开始了这个过程:
pm2 start ecosystem.config.js
然后一切顺利进行,就像在我的配置文件中写的那样(没有任何“观看”选项)。
实际的问题是:为什么这些进程在我的服务器上运行,但我无法回答。
https://stackoverflow.com/questions/35579857
复制相似问题