我一直在使用pm2一段時間。最近,我需要將一個自定義日誌目錄添加到名爲「actionLog」的Express4項目中。由於它是一個使用日誌文件進行更新的目錄,並且我不希望pm2在日誌文件更改時重新啓動應用程序,所以我希望pm2忽略該目錄。更新PM2到最新之後,這裏是我使用的命令:pm2 --ignore-watch不工作
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配置文件。目前,使用與忽略手錶這個配置文件也導致錯誤,但不是一個詳細的堆棧跟蹤上面,我只看到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。請參閱:http://pm2.keymetrics.io/docs/usage/quick-start/。如果您在配置文件中使用它,則使用ignore_watch。爲此,請參閱:http://pm2.keymetrics.io/docs/usage/watch-and-restart/ – woz