hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.61k stars 4.87k forks source link

Hexo Server Error: System limit for number of file watchers reached #4916

Open dimaslanjaka opened 2 years ago

dimaslanjaka commented 2 years ago

Check List

Please check followings before submitting a new issue.

Behavior

System limit for number of file watchers reached when run hexo server.

How to reproduce?

git clone https://github.com/dimaslanjaka/dimaslanjaka.github.io/tree/compiler/
git checkout compiler
npm install
gulp article:copy
hexo server

Is the problem still there under "Safe mode"?

image

Environment & Settings

Node.js & npm version(node -v && npm -v)

hexo: 6.0.0
hexo-cli: 4.3.0
os: linux 5.13.0-35-generic Zorin OS 16.1
node: 14.18.1
v8: 8.4.371.23-node.84
uv: 1.42.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.17.2
modules: 83
nghttp2: 1.42.0
napi: 8
llhttp: 2.1.4
openssl: 1.1.1l
cldr: 39.0
icu: 69.1
tz: 2021a
unicode: 13.0

Hexo and Plugin version(npm ls --depth 0 | grep "hexo")

├── @types/hexo@3.8.7 -> ./packages/hexo-blogger-xml/packages/@types/hexo
├── hexo-adsense@1.0.26 -> ./packages/hexo-adsense
├── hexo-asset-link@2.1.1
├── hexo-blogger-xml@1.0.27 -> ./packages/hexo-blogger-xml
├── hexo-browsersync@2.0.0 (git+ssh://git@github.com/hexojs/hexo-browsersync.git#04c02cd11eb3ecc2787dd0260ddffa86f82325b8)
├── hexo-front-matter@3.0.0 (git+ssh://git@github.com/hexojs/hexo-front-matter.git#72b55332794071b64c1840b5c135ff63e396a9af)
├── hexo-fs@3.1.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-feed@3.0.0 -> ./packages/hexo-generator-feed
├── hexo-generator-index@2.0.0
├── hexo-generator-json-content@4.2.3
├── hexo-generator-search@2.4.3 -> ./packages/hexo-generator-search
├── hexo-generator-tag@1.0.0
├── hexo-github-card@1.0.5
├── hexo-i18n@1.0.0
├── hexo-log@3.0.0
├── hexo-pagination@2.0.0
├── hexo-pdf@1.1.1
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-markdown-it-plus@1.0.4 (git+ssh://git@github.com/CHENXCHEN/hexo-renderer-markdown-it-plus.git#f2dd1b25738992efc391ba9da398a9c6a7efb105)
├── hexo-renderer-pug@3.0.0 (git+ssh://git@github.com/hexojs/hexo-renderer-pug.git#5f862af42bb2171ca3b2aa4b46e2253607e23827)
├── hexo-renderer-sass@0.4.0
├── hexo-renderer-stylus@2.0.1
├── hexo-renderer-swig@1.1.0
├── hexo-seo@1.0.31 -> ./packages/hexo-seo
├── hexo-server@3.0.0
├── hexo-theme-amp@1.2.0 -> ./themes/amp
├── hexo-theme-hueman@0.5.0 -> ./themes/hueman
├── hexo-util@2.6.0
├── hexo@6.0.0

Your package.json package.json

{
  "name": "gh-pages",
  "version": "1.0.1",
  "private": true,
  "main": "main.js",
  "scripts": {
    "start": "npx ts-node src/express/app.ts",
    "build": "node deploy.js",
    "skip-heroku-postbuild": "npm i -g gulp gulp-cli typescript ts-node && npm install && npx gulp article:copy",
    "generate": "hexo generate",
    "generate:clean": "hexo clean && hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server",
    "server:clean": "npm run clean && hexo server",
    "dev": "ts-node src/electron-express.ts",
    "dev:tsc": "tsc --watch",
    "dev:express": "npx nodemon --config nodemon.json",
    "dev:electron": "npx nodemon --config nodemon-electron.json -L",
    "firebase": "firebase deploy",
    "firebase:local": "firebase emulators:start --project android-008",
    "firebase:preview": "firebase hosting:channel:deploy --project android-008",
    "intaller": "npm install --save hexo-autoprefixer hexo-filter-cleanup hexo-generator-feed hexo-generator-sitemap hexo-renderer-sass hexo-renderer-swig mamboer/lunr.js moment node-sass object-assign",
    "fix-sharp": "rm node_modules/sharp -rf && npm install --ignore-scripts=false --verbose sharp",
    "lint": "eslint . --ext .ts",
    "lint:format": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
    "postinstall": "cd themes/material && npm install",
    "wsl-install": "rm -r node_modules && npm install --platform=win32",
    "prototypes": "npm un js-prototypes && npm i git+https://github.com/dimaslanjaka/js-prototypes.git"
  },
  "engines": {
    "node": ">=12.22.6",
    "npm": ">=6.x"
  },
  "hexo": {
    "version": "6.0.0"
  },
  "dependencies": {
    "chalk": "^4.1.2",
    "crypto-js": "^4.0.0",
    "firebase": "^9.3.0",
    "folder-hash": "^4.0.1",
    "fs-extra": "^10.0.0",
    "google-news-sitemap": "file:packages/google-news-sitemap",
    "gulp-cache": "^1.1.3",
    "gulp-imagemin": "^8.0.0",
    "hexo": "^6.0.0",
    "hexo-adsense": "file:packages/hexo-adsense",
    "hexo-asset-link": "^2.1.0",
    "hexo-blogger-xml": "file:packages/hexo-blogger-xml",
    "hexo-browsersync": "github:hexojs/hexo-browsersync",
    "hexo-front-matter": "github:hexojs/hexo-front-matter",
    "hexo-fs": "^3.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "file:packages/hexo-generator-feed",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-json-content": "^4.2.3",
    "hexo-generator-search": "file:packages/hexo-generator-search",
    "hexo-generator-tag": "^1.0.0",
    "hexo-github-card": "^1.0.5",
    "hexo-i18n": "^1.0.0",
    "hexo-log": "^3.0.0",
    "hexo-pagination": "^2.0.0",
    "hexo-pdf": "^1.1.1",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-markdown-it-plus": "github:CHENXCHEN/hexo-renderer-markdown-it-plus",
    "hexo-renderer-pug": "github:hexojs/hexo-renderer-pug",
    "hexo-renderer-sass": "^0.4.0",
    "hexo-renderer-stylus": "^2.0.1",
    "hexo-renderer-swig": "^1.1.0",
    "hexo-seo": "file:packages/hexo-seo",
    "hexo-server": "^3.0.0",
    "hexo-theme-amp": "file:themes/amp",
    "hexo-theme-hueman": "file:themes/hueman",
    "hexo-util": "^2.5.0",
    "imagemin": "^6.1.0",
    "imagemin-giflossy": "^5.1.10",
    "imagemin-gifsicle": "^6.0.1",
    "imagemin-jpeg-recompress": "^6.0.0",
    "imagemin-jpegtran": "^6.0.0",
    "imagemin-mozjpeg": "^9.0.0",
    "imagemin-optipng": "^6.0.0",
    "imagemin-pngquant": "^7.0.0",
    "imagemin-svgo": "^7.0.0",
    "imagemin-webp": "^5.0.0",
    "imagemin-zopfli": "^7.0.0",
    "jsdom": "^16.6.0",
    "lunr": "github:mamboer/lunr.js",
    "markdown-it-attrs": "file:packages/markdown-it-attrs",
    "minimatch": "^3.0.4",
    "moment": "^2.29.1",
    "node-libcurl": "^2.3.3",
    "node-sass": "^6.0.1",
    "object-assign": "^4.1.1",
    "rimraf": "^3.0.2",
    "showdown": "^1.9.1",
    "xml": "^1.0.1",
    "yaml": "^1.10.2"
  },
  "devDependencies": {
    "@types/browser-sync": "^2.26.1",
    "@types/cookie-parser": "^1.4.2",
    "@types/cors": "^2.8.10",
    "@types/cross-spawn": "^6.0.2",
    "@types/crypto-js": "^4.0.1",
    "@types/electron": "^1.6.10",
    "@types/express": "^4.17.12",
    "@types/express-session": "^1.17.3",
    "@types/folder-hash": "^4.0.1",
    "@types/gulp": "^4.0.9",
    "@types/hexo": "^3.8.7",
    "@types/html-minifier-terser": "^6.0.0",
    "@types/jest": "^26.0.23",
    "@types/jquery": "^3.5.5",
    "@types/jsdom": "^16.2.11",
    "@types/lodash": "^4.14.173",
    "@types/method-override": "^0.0.31",
    "@types/minimatch": "^3.0.5",
    "@types/node": "^15.14.9",
    "@types/nodemon": "^1.19.0",
    "@types/pako": "^1.0.1",
    "@types/request": "^2.48.7",
    "@types/rimraf": "^3.0.2",
    "@types/serve-index": "^1.7.30",
    "@types/serve-static": "^1.13.9",
    "@types/showdown": "^1.9.3",
    "@types/sitemap-generator": "^8.5.1",
    "@types/swfobject": "^2.2.27",
    "@types/through2": "^2.0.36",
    "@types/toastr": "^2.1.38",
    "@types/xml": "^1.0.7",
    "@types/yargs": "^17.0.5",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "babel-eslint": "^10.1.0",
    "body-parser": "^1.19.0",
    "browser-sync": "^2.27.7",
    "cookie-parser": "^1.4.5",
    "cors": "^2.8.5",
    "cross-spawn": "^7.0.3",
    "errorhandler": "^1.5.1",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-ejs": "^0.0.2",
    "eslint-plugin-markdown": "^2.2.0",
    "eslint-plugin-prettier": "^3.4.1",
    "gulp": "^4.0.2",
    "html-minifier-terser": "^5.1.1",
    "md5-file": "^5.0.0",
    "ngrok": "^4.2.2",
    "pako": "^2.0.3",
    "prettier": "^2.4.1",
    "request": "^2.88.2",
    "response-time": "^2.3.2",
    "sanitize-filename": "^1.6.3",
    "serve-index": "^1.9.1",
    "serve-static": "^1.14.2",
    "through2": "^4.0.2",
    "ts-node": "^10.2.1",
    "tslib": "^2.3.1",
    "typescript": "^4.4.3"
  }
}

_config.yml

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: "WMI"
subtitle: "Website Management Indonesia"
description: Website Management Indonesia is a blog about scripts, tips and tricks, games, software. Covering php, javascript, jquery, mysql, seo, e-commerce and others.
subtitle_desc: "External source WMI Github Laboratory"
keywords: the legend of neverland, genshin impact, games, how to, tips and tricks, php, javascript, jquery, mysql, seo, e-commerce
language:
  - en
  - id
timezone: "Asia/Jakarta"
introduction: "introduction"

# https://github.com/wzpan/hexo-generator-search
# https://github.com/next-theme/hexo-generator-searchdb
search:
  path: search.xml
  field: post
  content: true
  format: html
  #template: ./template/search.xml

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://www.webmanajemen.com/
root: /
permalink: :title.html #:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: docs
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
# https://hexo.io/docs/configuration.html
skip_render:
  - "yandex_*.html"
  - "Midi"
  - "Midi/**/*"
  - "page"
  - "page/**/*"
  - "backend"
  - "backend/**/*"
  # https://github.com/hexojs/hexo/issues/1797
  - "*.json"
  - "**/*.json"
  - "_posts/**/*.json"
  - "_posts/**/*.js"
  - "_posts/**/*.css"
  - "_posts/The Legend Of Neverland/Midi/readme.md"
  - "**/__test__/**"
  - "_posts/Chimeraland/**/*.html"

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ""
filename_case: 0
render_drafts: false

# https://hexo.io/docs/asset-folders
post_asset_folder: true

relative_link: false
future: true
# https://github.com/hexojs/hexo-util
# https://hexo.io/docs/syntax-highlight.html
highlight:
  enable: true
  line_number: false
  auto_detect: false
  tab_replace: "  " # replace tabs with 2 spaces
  wrap: false
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ""

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ""
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

## Use post's date for updated date unless set in front-matter
updated_option: false

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# https://www.npmjs.com/package/hexo-server
server:
  port: 8000
  log: false
  ip: 0.0.0.0
  host: adsense.webmanajemen.com
  proxy: adsense.webmanajemen.com
  compress: false
  cache: false
  header: false
  serveStatic:
    extensions:
      - html

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/

theme: hueman

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/dimaslanjaka/dimaslanjaka.github.io
  branch: master
  message: "Git Deployment: {{ now('YYYY-MM-DD HH:mm:ss') }}"

author:
  name: "Dimas Lanjaka"
  link: "https://www.webmanajemen.com/"
  image:
    url: https://res.cloudinary.com/dimaslanjaka/image/fetch/https://imgdb.net/images/3600.jpg
    width: 1944 # <= 600
    height: 2592 # >= 60

social_links:
  github: https://github.com/dimaslanjaka
  youtube: https://youtube.com/p/L3n4r0x

# Feed Atom https://github.com/hexojs/hexo-generator-feed
feed:
  # include contents in feeds
  content: true
  # Generate both atom and rss2 feeds
  type:
    - atom
    - rss2
  path:
    - atom.xml
    - rss.xml

# Sitemap
sitemap:
  path: sitemap.xml

# https://github.com/sergeyzwezdin/hexo-related-posts#Configuration
related_posts:
  enabled: true
  enable_env_name: prod
  filter_threshold: 0.3
  related_count: 3
  weight:
    title: 0.05
    description: 0.05
    keywords: 0.01
    tags: 0.005
    categories: 0.005
    text: 1
  stemmers:
    - en
    - ru
    - id
  reserved:
    - asp.net
    - vs.net
    - ado.net
    - .net
    - games
    - js
    - ts

# https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus.git
markdown_it_plus:
  highlight: true
  html: true
  xhtmlOut: true
  breaks: true
  langPrefix:
  linkify: true
  typographer:
  #quotes: “”‘’
  pre_class: highlight
  plugins:
    - plugin:
        # https://www.npmjs.com/package/markdown-it-attrs
        name: markdown-it-attrs
        enable: true
        options:
          leftDelimiter: "{"
          rightDelimiter: "}"
          allowedAttributes: [] # empty array = all attributes are allowed

# https://github.com/hexojs/hexo-browsersync
browsersync:
  logLevel: "warn"
  ghostMode:
    scroll: true
  instanceName: "customInstance"
  port: 3001
  browser: "firefox"
  open: false

# https://github.com/dimaslanjaka/hexo-adsense
adsense:
  enable: true
  pub: ca-pub-1165447249910969
  # in-article ads source
  article_ads:
    - "source/ads/in_article.html"
    - "source/ads/in_article2.html"
  # ads field
  field: "site" # post=only post, site=all pages and posts
  # auto redirect to https
  https: false
  # block user with adblock enabled
  adblock: false
  # amp or javascript
  type: amp
  # exclude pattern, disable adding adsense
  exclude:
    - "*.min.html"
    - "exclude/**/*"

# next project: hexo-analytics
analytics:
  # google tag manager
  tagmanager: GTM-NJNNXSR
  # google analytics v4
  GA4: G-BG75CLNJZ1
  # google analytics
  GA3: UA-106238155-1
  # cloudflare web statistics
  cloudflare: 2157c0f3b9e74a92badffe39156166b9

# https://github.com/dimaslanjaka/hexo-seo
seo:
  html:
    # fix invalid html
    fix: true
    # exclude from minify
    exclude:
      - "*.min.{htm,html}"
  css: true
  js: true
  schema: false
  img:
    # fix broken images
    broken: false
    # default broken images
    default: https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg
    # broken images methods
    # serverside : process broken images from server side (caused javascript heap out of memory, if your post large and your device has insufficient memory)
    # clientside : process broken image from client side browser with webjs
    onerror: serverside
  # external links fix
  links:
    # enable or false
    enable: true
    # allowed following links, otherwise nofollow others
    exclude:
      - webmanajemen.com
      - web-manajemen.blogspot.com
      - dimaslanjaka.github.io
  sitemap: true

Others

I have a thousand posts.

SukkaW commented 2 years ago

https://hexo.io/docs/troubleshooting#EMFILE-Error Will it helps?

dimaslanjaka commented 2 years ago

https://hexo.io/docs/troubleshooting#EMFILE-Error Will it helps?

ill try later at the office (working hours)

dimaslanjaka commented 2 years ago

https://hexo.io/docs/troubleshooting#EMFILE-Error Will it helps?

this tips using a large resources of my pc. there no option to exclude files/folders from file watcher when run hexo server ?

NaZawsze commented 1 year ago

You can try this

React Native Error: ENOSPC: System limit for number of file watchers reached

Increase fs.inotify.max_user_watches in docker container #628

dimaslanjaka commented 1 year ago

For now I'm using my own post generator. If there is a theme change, I will change the source post from "hexo theme unit test" so that not too many posts are listened to.

https://github.com/dimaslanjaka/static-blog-generator

now i can manage thousands of articles without consuming too much pc resources by processing posts, site generator separately and also using CI to automated it https://github.com/dimaslanjaka/static-blog-generator-hexo/actions