Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.31k stars 2.61k forks source link

pm2-dev doesn't detect file changes, pm2-runtime --watch does #4915

Open hyperknot opened 3 years ago

hyperknot commented 3 years ago

What's going wrong?

  1. Using yarn pm2-dev server.js usually doesn't pick up file changes in server.js. Once in a while it works, but usually it doesn't.
  2. yarn pm2-runtime start server.js --watch always picks up file changes, 100% reliably.

How could we reproduce this issue?

Create an empty server.js and put console.log(1) into it. Change 1 -> 2.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Wed Nov 11 2020 19:18:22 GMT+0100 (Central European Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.0
node version         : 10.20.1
node path            : /Users/user/Documents/dev/maphub/web/socketio/node_modules/.bin/pm2
argv                 : /Users/user/.nvm/versions/node/v10.20.1/bin/node,/Users/user/Documents/dev/maphub/web/socketio/node_modules/pm2/lib/Daemon.js
argv0                : /Users/user/.nvm/versions/node/v10.20.1/bin/node
user                 : user
uid                  : 501
gid                  : 20
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.0
node version         : 10.20.1
node path            : /Users/user/Documents/dev/maphub/web/socketio/node_modules/.bin/pm2
argv                 : /Users/user/.nvm/versions/node/v10.20.1/bin/node,/Users/user/Documents/dev/maphub/web/socketio/node_modules/.bin/pm2,report
argv0                : /Users/user/.nvm/versions/node/v10.20.1/bin/node
user                 : user
uid                  : 501
gid                  : 20
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : darwin
type                 : Darwin
cpus                 : Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
cpus nb              : 8
freemem              : 40710144
totalmem             : 8589934592
home                 : /Users/user
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/Users/user/.pm2/pm2.log last 20 lines:
PM2        | 2020-11-06T14:22:38: PM2 log: Stopping app:server id:0
PM2        | 2020-11-06T14:22:38: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2        | 2020-11-06T14:22:39: PM2 log: pid=53355 msg=process killed
PM2        | 2020-11-06T14:22:39: PM2 log: PM2 successfully stopped
PM2        | 2020-11-11T19:18:22: PM2 log: ===============================================================================
PM2        | 2020-11-11T19:18:22: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2020-11-11T19:18:22: PM2 log: Time                 : Wed Nov 11 2020 19:18:22 GMT+0100 (Central European Standard Time)
PM2        | 2020-11-11T19:18:22: PM2 log: PM2 version          : 4.5.0
PM2        | 2020-11-11T19:18:22: PM2 log: Node.js version      : 10.20.1
PM2        | 2020-11-11T19:18:22: PM2 log: Current arch         : x64
PM2        | 2020-11-11T19:18:22: PM2 log: PM2 home             : /Users/user/.pm2
PM2        | 2020-11-11T19:18:22: PM2 log: PM2 PID file         : /Users/user/.pm2/pm2.pid
PM2        | 2020-11-11T19:18:22: PM2 log: RPC socket file      : /Users/user/.pm2/rpc.sock
PM2        | 2020-11-11T19:18:22: PM2 log: BUS socket file      : /Users/user/.pm2/pub.sock
PM2        | 2020-11-11T19:18:22: PM2 log: Application log path : /Users/user/.pm2/logs
PM2        | 2020-11-11T19:18:22: PM2 log: Worker Interval      : 30000
PM2        | 2020-11-11T19:18:22: PM2 log: Process dump file    : /Users/user/.pm2/dump.pm2
PM2        | 2020-11-11T19:18:22: PM2 log: Concurrent actions   : 2
PM2        | 2020-11-11T19:18:22: PM2 log: SIGTERM timeout      : 1600
PM2        | 2020-11-11T19:18:22: PM2 log: ===============================================================================
cumt-robin commented 2 months ago

I have met a similar problem. I used pm2-dev as runtime in docker container, and I enabled the watch option in the configuration file, and I did the --mount bind when I ran the docker run command, the docker container ran successfully, but when I changed the source file, the server can't detect any change.

this is the run command:

docker run -dp 8002:8002 \
--mount type=bind,source=${PWD},target=/app \
--name blog-backend-dev \
blog-express-dev

and it shows that Watch and Restart is enabled

image

So, why doesn't the watch feature work ?