Sunday, 9 April 2017

Node error ENOSPC when running pm2 with docker-compose

When my pm2 service is launched I get the following error:

Error: watch /usr/src/app/node_modules/zip-stream/node-modules/loadash/... ENOSCP
    at exports._errnoException (util.js:1034:11)
    at FSWatcher.start (fs.js:1400:19)
    at Object.fs.watch (fs.js:1426:11)
    at createFsWatchInstance (/usr/local/lic/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    ....
    at FSReqWrap.oncomplete (fs.js:114:15)

This occurs only when I use the command:

docker-compose --build up

If I run the pm2 command inside the docker:

docker-compose exec downtorrent_back_dev bash

sh start.sh

then, it starts the service without any problems.

This is the docker-compose.yml file:

version: '3'
services:
  downtorrent_back:
    container_name: downtorrent_back_dev
    build:
      context: .
      dockerfile: Dockerfile-back.dev
    volumes:
      - ./back:/usr/src/app
    expose:
      - "10002"
      - "9090"
      - "51413"
    ports:
      - "10002:10002"
      - "9090:9090"

This the script start.sh that starts the service:

#!/bin/bash

# Fix limit on system for watching files
echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p
npm dedupe

# Start transmission torrent client
service transmission-daemon start
# Start service
pm2 start start.config.json --only downtorrent --env dev --no-daemon

And this is the PM2 config file:

{
  "apps": [{
    "name": "downtorrent",
    "script": "./app.js",
    "watch": true,
    "ignoreWatch": ["newrelic_agent.log"],
    "instances": 2,
        "log_date_format" : "DD-MM-YYYY HH:mm Z",
    "exec_mode": "cluster",
    "env": {
      "NODE_ENV": "dev",
      "APP_PORT": 10002
    }
  }]
}

As you can see, I've already tried the proposed solution in this question for the ENOSCP problem, but still not working.



via daniegarcia254

No comments:

Post a Comment