docker-pm2 icon indicating copy to clipboard operation
docker-pm2 copied to clipboard

pm2-dev does not restart server on file changes

Open soosap opened this issue 7 years ago • 3 comments

I have the following docker-compose.yml file:

version: '3.2'

services:
  backend:
    image: keymetrics/pm2-docker-alpine:8
    ports:
      - 3000:3000
    working_dir: /var/www
    command: ["pm2-dev", "start", "process.yml"]
    volumes:
      - "../..:/var/www"

I am further using the following process.yml pm2 configuration:

---
apps:
  - script: 'src/server.js'
    name: 'my-app'
    interpreter: 'babel-node'
    cwd: '/var/www'

The app starts alright. Unfortunately, it does not react to file changes. docker exec -it <container_id> sh 'ing into the container, I see that the file changes are propagated correctly. Yet, the server is not being restarted from within the container.

Trying the same thing outside a docker container works as expected. File changes trigger a restart with pm2-dev.

soosap avatar Jun 27 '17 17:06 soosap

I am facing the same issue. Any updates?

itzrahulsoni avatar Sep 27 '17 10:09 itzrahulsoni

I had the same issue. Took me 2 hours to find this...

When working with NFS devices you’ll need to set usePolling: true as stated in this chokidar issue.

Bottom of the page: http://pm2.keymetrics.io/docs/usage/watch-and-restart/

hehachris avatar Dec 08 '17 17:12 hehachris

As stated by @hehachris adding usePolling: true in the ecosystem.config.js file worked for me.

module.exports = {
    apps: [
        {
            name: 'token',
            script: 'app.js',
            watch: true,
            "watch_options": {
                usePolling: true
            },
            env: {
                PORT: 3002
            },
            env_production: {
                NODE_ENV: 'production'
            }
        }
    ]
};

bruceragon avatar Jun 23 '18 11:06 bruceragon