2016-02-23 63 views
3

我一直在使用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 

我已經看了一些的如忽視,看問題的報告:

不幸的是,我仍然堅持。有任何想法嗎?

回答

1

事實證明,即使錯誤被忽略手錶引發的,它們不是由它引起的。下面的命令修復問題:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p 

我在這裏找到這個解決方案:https://stackoverflow.com/a/32600959/2234029

我也嘗試過「故宮重複數據刪除」 - 如建議對thread-這並沒有幫助。

0

我認爲這是ignore_watch即帶下劃線

+1

命令行參數是--ignore-watch。請參閱:http://pm2.keymetrics.io/docs/usage/quick-start/。如果您在配置文件中使用它,則使用ignore_watch。爲此,請參閱:http://pm2.keymetrics.io/docs/usage/watch-and-restart/ – woz

0

你有兩個選擇:

  1. 增加系統的inotify最大的手錶極限:
    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"
  • 如果你沒有須藤權限選項2是給你的。