[ Node | PM2 ] watch 模式下無限重啓

最初配置的ecosystem.config.js

module.exports = {
  apps: [
    {
      name: 'development_platform_server',
      script: 'bin/www',
      instances: 1,
      autorestart: true,
      watch: true,
      out_file: './logs/out.log',
      error_file: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      max_memory_restart: '500M'
    }
  ]
}

然後就無限重啓了
在這裏插入圖片描述
從下面的錯誤日誌中可以發現, logs文件內的文件改變,觸發了 watch 的監聽檢測。

error: Change detected on path logs/error-0.log for app development_platform_server

修改後的ecosystem.config.js,使用ignore_watch屬性去忽略一些不想監聽的。

module.exports = {
  apps: [
    {
      name: 'development_platform_server',
      script: 'bin/www',
      instances: 1,
      autorestart: true,
      watch: true,
      out_file: './logs/out.log',
      error_file: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      max_memory_restart: '500M',
      ignore_watch: 'logs'
    }
  ]
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章