docker-pm2
docker-pm2 copied to clipboard
pm2-dev does not restart server on file changes
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.
I am facing the same issue. Any updates?
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/
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'
}
}
]
};