使用docker-compose

时间:2017-04-09 10:46:15

标签: node.js bash docker docker-compose pm2

当我的 pm2 服务启动时,我收到以下错误:

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)

只有在使用以下代码构建和运行docker时才会发生这种情况:

  

docker-compose --build up

如果我只构建docker,然后在docker中命令:

  

docker-compose exec downtorrent_back_dev bash

     

sh start.sh

然后,它启动服务没有任何问题。

这是 docker-compose.yml 文件:

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"

启动服务的脚本 start.sh

#!/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

这是 PM2配置文件

{
  "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
    }
  }]
}

正如您所看到的,我已经在this question中尝试了针对ENOSCP问题的建议解决方案,但仍无效。

0 个答案:

没有答案