Unitech / Unitech/pm2

pm2 watch argument doesn't watch the files

Open
#4,533 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Inspecting S: Need More Data
Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

I am using PM2 with the following configuration:

module.exports = {
  apps : [{
    name: 'sandbox',
    script: 'index.js',
    args: ["PORT=8084", "--color"],
    instances: 1,
    autorestart: true,
    watch: 'index.js',
    out_file: "logs/out.log",
    node_args: "--trace-warnings"
  }]
};

All works well except that changes in index.js don't trigger restart.

I have tried many things:

  • adding the absolute path in script and in the watch
  • adding cwd with the absolute path
  • Using variations in the watch like ./index.js or ../ or ./ or true
  • Removing autorestart

Additional info:
My app use express

The status shows that watch is enabled:

│ status            │ online
│ name              │ sandbox
│ version           │ 1.0.0
│ restarts          │ 0
│ uptime            │ 8m                                                 │
│ script path       │ /var/www/api/index.js                              │
│ script args       │ PORT=8084 --color                                  │
│ error log path    │ /home/ubuntu/.pm2/logs/sandbox-error-10.log        │
│ out log path      │ /var/www/api/logs/out-10.log                       │
│ pid path          │ /home/ubuntu/.pm2/pids/sandbox-10.pid              │
│ interpreter       │ node                                               │
│ interpreter args  │ --trace-warnings                                   │
│ script id         │ 10                                                 │
│ exec cwd          │ /var/www/api                                       │
│ exec mode         │ cluster_mode                                       │
│ node.js version   │ 11.10.0                                            │
│ node env          │ N/A                                                │
│ watch & reload    │ ✔                                                  │
│ unstable restarts │ 0                                                  │
│ created at        │ 2019-11-30T10:45:14.704Z

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 the problem with the shown PM2 configuration and /var/www/api/index.js, then change index.js while watching the PM2 status and logs. Trace the watch and reload behavior from this configuration; done means an index.js change reliably triggers an application restart.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.