我已经使用pm2一段时间了.最近,我需要在我的Express4项目中添加一个名为“actionLog”的自定义日志目录.由于它是一个使用日志文件更新的目录,我不希望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"
这也产生了同样的错误.
一旦我有正确的ignore-watch参数,我将更新用于启动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
我查看了一些忽略观察问题的报告,例如:
> https://github.com/Unitech/PM2/issues/1288
> https://github.com/Unitech/PM2/issues/918
> https://github.com/Unitech/PM2/issues/1275
> How to auto reload project nodejs use pm2
> Express 4 + pm2 watch not working
不幸的是,我仍然被卡住了.有任何想法吗?
即使错误是由ignore-watch触发的,它们也不是由它引起的.以下命令修复了该问题:echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
我在这里找到了这个解决方案:https://stackoverflow.com/a/32600959/2234029
我也尝试了“npm重复数据删除” – 这个线程上的建议 – 没有帮助.