Open chrisdemetriad opened 4 years ago
I can confirm this
pm2 --version
=> 4.2.3
Mac running Vagrant (Virtualbox) with generic/debian10 box
Running pm2 start index.js --watch
triggers the watch (pm2 restarts when files change on a vagrant shared folder)
but
Running pm2 start all
or pm2 start --only index
(using ecosystem.config.js) does not trigger a restart even if pm2 status
says watch is enabled
module.exports = {
// PM2 Documentation
// https://pm2.io/doc/en/runtime/overview/
// ==================== APPS ====================
apps: [{
name: 'index',
cwd: '/var/www/project/nodejs/',
script: 'index.js',
node_args: '--harmony',
combine_logs: true,
out_file: '/home/project/.pm2/logs/access.log',
error_file: '/home/project/.pm2/logs/error.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss',
restart: true,
watch_options: {
usePolling: true,
interval: 500,
},
ignore_watch: ['logs', 'public', 'views', 'app/commands'],
env: {
watch: true,
NODE_ENV: 'development',
},
env_dev: {
watch: false,
NODE_ENV: 'development',
},
env_staging: {
watch: false,
NODE_ENV: 'staging',
},
env_production: {
watch: false,
NODE_ENV: 'production',
},
}],
}
Another thing I noticed is that with the pm2 start index.js --watch
, the logs show
PM2 | [Watch] Start watching index
PM2 | App [index:1] starting in -fork mode-
PM2 | App [index:1] online
When starting with pm2 start --only index
, it does not show the [Watch]
line above
PM2 | App [index:1] starting in -fork mode-
PM2 | App [index:1] online
This also seems to be working pm2 start --only index --watch
(adding --watch) but this is probably just suffixing the ".js" file at the end of index
so not really using the ecosystem.config.js file
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This still happens in 4.4.4.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
No update has been released in the meantime, i.e. this is still an open issue. Will retest at the next stale notification if needed.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Still on 4.4.4
I never managed to make default watch settings work in Ubuntu, however using polling via advanced watch options worked:
"watch": true,
"ignore_watch" : ["node_modules"],
"watch_options": {
"usePolling": true,
"interval": 1000
}
More info: https://github.com/buunguyen/PM2/blob/master/ADVANCED_README.md#watch--restart https://github.com/paulmillr/chokidar#api
What's going wrong?
Using a ecosystem file to manage a few scripts, the watch property doesn't watch for file changes.
Whatever paths/values I use in the watch property (absolute, relative,
true
), if I add one, or in the script name, it doesn't work. I spent two days on it.It doesn't work.
Changes to
test1.js
doesn't trigger a restart. If I starttest3.js
manually withpm2 start bots/test3.js --watch
, then changes totest1.js
will trigger a restart.process.cwd()
returns/home/chris
.How could we reproduce this issue?
processes.json
pm2 start processes.json
pm2 list
shows all files are watchingtest1.js
- no restart.pm2 start test3.js --watch
.pm2 list
, if all good, thentest1.js
-test3.js
will see the change and restart.Supporting information