Unitech / Unitech/pm2

Watch doesn't watch for file changes (ecosystem json file)

Open
#4,598 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

Using a ecosystem file to manage a few scripts, the watch property doesn't watch for file changes.

Whatever paths I use in the watch property (absolute, relative, "true"), if I add one, or in the script name, it doesn't work. Spent two days on it.

It doesn't work.

Changes to test1.js doesn't trigger a restart.
If I start test3.js manually with pm2 start bots/test3.js --watch, changes to test1.js will trigger a restart. process.cwd() returns /home/chris. All the above happens whether processes.json is started from /home/chris/bots or /home/chris.

How could we reproduce this issue?

  1. Use processes.json
  2. Load two scripts as below
  3. Start with pm2 start processes.json
  4. pm2 list shows all files are watching
  5. Edit test1.js - no restart.
  6. Start individual script: pm2 start test3.js --watch.
  7. Check with pm2 list, if all good, then
  8. Edit test1.js - test3.js will see the change and restart.

Supporting information

chris@localhost:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
chris@localhost:~$ cat bots/bots.json
[
        {
                "name": "test1",
                "script": "./bots/test1.js",
                "watch": "./bots/test1.js"
        },
        {
                "name": "test2",
                "script": "./bots/test2.js",
                "cwd": "./bots",
                "watch": true,
                "ignore_watch": [
                        "db",
                        "/db"
                ],
                "watch_options": {
                        "followSymlinks": false
                }
        },
...

chris@localhost:~$ pm2 report

--- PM2 REPORT (Wed Feb 05 2020 15:13:47 GMT+0000 (Coordinated Universal Time))

--- Daemon -------------------------------------------------
pm2d version         : 3.0.3
node version         : 12.12.0
node path            : /usr/bin/pm2
argv                 : /home/chris/.nvm/versions/node/v12.12.0/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : chris
uid                  : 1000
gid                  : 1000
uptime               : 42min

--- CLI ----------------------------------------------------
local pm2            : 3.0.3
node version         : 12.12.0
node path            : /usr/bin/pm2
argv                 : /home/chris/.nvm/versions/node/v12.12.0/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : chris
uid                  : 1000
gid                  : 1000

--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : AMD EPYC 7601 32-Core Processor
cpus nb              : 1
freemem              : 743907328
totalmem             : 2090225664
home                 : /home/chris

--- PM2 list -----------------------------------------------
┌────────────────────┬────┬──────┬───────┬────────┬─────────┬────────┬──────┬───────────┬──────┬──────────┐
│ App name           │ id │ mode │ pid   │ status │ restart │ uptime │ cpu  │ mem       │ user │ watching │
├────────────────────┼────┼──────┼───────┼────────┼─────────┼────────┼──────┼───────────┼──────┼──────────┤
│ test1        │ 1  │ fork │ 14937 │ online │ 31      │ 5m     │ 0.1% │ 38.2 MB   │ chris │ enabled  │
│ test2           │ 0  │ fork │ 14930 │ online │ 31      │ 5m     │ 0%   │ 38.2 MB   │ chris │ enabled  │


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with the ecosystem file shown as processes.json or bots/bots.json, using pm2 start processes.json and pm2 list. Start by tracing PM2's ecosystem-file watch handling and compare it with pm2 start test3.js --watch. Done means editing test1.js reliably triggers the expected process restart when launched from the ecosystem file.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.