ignore_watch does not work and --ignore barely works
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
Problems with ignore_watch and --ignore
I recently moved to pm2 from nodemon and a project that I am currently working on stores blob files uploaded by a user in a temporary uploads directory and then moves it to the database at a convenient time. Also, when the user wants to download a folder and/or multiple files, it packages them into a zip file which is stored in a temporary downloads directory. The problem I was running into was that when the user uploaded a file, pm2 picked it up as a file change and restarted the server. This resulted in an ERR_CONNECTION_RESET at the client side. When I tried to tell pm2 to ignore the uploads and downloads directories in the JSON file using ignore_watch, it did not work. I tried variations of the folder paths but nothing happened. This was the JSON file:
{
"apps": [{
"name" : "My App",
"script" : "node app.js",
"ignore_watch" : ["uploads", "downloads"]
}]
}
pm2 still only picked up node_modules as an ignored directory. I then tried to use pm2-dev start process.json --ignore 'downloads uploads' instead of ignore_watch. This resulted in only the downloads directory being ignored, suggesting that pm2 only ignores the first directory from the supplied list. Just in case, I was giving malformed input, I also tried comma separated values and passing in an array but that resulted in uploads, downloads and [uploads, being ignored respectively.
Comma Separation Result for --ignore:

Array Result for --ignore:

Workaround I used
I just moved all directories I didn't want to be watched into a single directory called data and ignored that using --ignore as follows:

Edit
I forgot to include the following information:
// NodeJS Version
$ node --version
v14.15.4
// PM2 version
$ pm2 --version
4.5.4
// PM2 logs
$ head -n 50 ~/.pm2/pm2.log
2021-02-21T13:02:57: PM2 log: ===============================================================================
2021-02-21T13:02:57: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2021-02-21T13:02:57: PM2 log: Time : Sun Feb 21 2021 13:02:57 GMT+0530 (India Standard Time)
2021-02-21T13:02:57: PM2 log: PM2 version : 4.5.4
2021-02-21T13:02:57: PM2 log: Node.js version : 14.15.4
2021-02-21T13:02:57: PM2 log: Current arch : x64
2021-02-21T13:02:57: PM2 log: PM2 home : /home/nilanjan/.pm2
2021-02-21T13:02:57: PM2 log: PM2 PID file : /home/nilanjan/.pm2/pm2.pid
2021-02-21T13:02:57: PM2 log: RPC socket file : /home/nilanjan/.pm2/rpc.sock
2021-02-21T13:02:57: PM2 log: BUS socket file : /home/nilanjan/.pm2/pub.sock
2021-02-21T13:02:57: PM2 log: Application log path : /home/nilanjan/.pm2/logs
2021-02-21T13:02:57: PM2 log: Worker Interval : 30000
2021-02-21T13:02:57: PM2 log: Process dump file : /home/nilanjan/.pm2/dump.pm2
2021-02-21T13:02:57: PM2 log: Concurrent actions : 2
2021-02-21T13:02:57: PM2 log: SIGTERM timeout : 1600
2021-02-21T13:02:57: PM2 log: ===============================================================================
2021-02-21T13:07:51: PM2 log: App [app:0] starting in -fork mode-
2021-02-21T13:07:51: PM2 log: App [app:0] online
2021-02-21T13:08:38: PM2 log: Stopping app:app id:0
2021-02-21T13:08:38: PM2 log: App [app:0] exited with code [0] via signal [SIGINT]
2021-02-21T13:08:38: PM2 log: pid=35262 msg=process killed
2021-02-22T18:34:22: PM2 log: ===============================================================================
2021-02-22T18:34:22: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2021-02-22T18:34:22: PM2 log: Time : Mon Feb 22 2021 18:34:22 GMT+0530 (India Standard Time)
2021-02-22T18:34:22: PM2 log: PM2 version : 4.5.4
2021-02-22T18:34:22: PM2 log: Node.js version : 14.15.4
2021-02-22T18:34:22: PM2 log: Current arch : x64
2021-02-22T18:34:22: PM2 log: PM2 home : /home/nilanjan/.pm2
2021-02-22T18:34:22: PM2 log: PM2 PID file : /home/nilanjan/.pm2/pm2.pid
2021-02-22T18:34:22: PM2 log: RPC socket file : /home/nilanjan/.pm2/rpc.sock
2021-02-22T18:34:22: PM2 log: BUS socket file : /home/nilanjan/.pm2/pub.sock
2021-02-22T18:34:22: PM2 log: Application log path : /home/nilanjan/.pm2/logs
2021-02-22T18:34:22: PM2 log: Worker Interval : 30000
2021-02-22T18:34:22: PM2 log: Process dump file : /home/nilanjan/.pm2/dump.pm2
2021-02-22T18:34:22: PM2 log: Concurrent actions : 2
2021-02-22T18:34:22: PM2 log: SIGTERM timeout : 1600
2021-02-22T18:34:22: PM2 log: ===============================================================================
2021-02-22T18:34:22: PM2 log: App [Hyve:0] starting in -fork mode-
2021-02-22T18:34:22: PM2 log: App [Hyve:0] online
2021-02-22T18:40:22: PM2 log: Stopping app:Hyve id:0
2021-02-22T18:40:22: PM2 log: App [Hyve:0] exited with code [0] via signal [SIGINT]
2021-02-22T18:40:22: PM2 log: pid=20195 msg=process killed
2021-02-22T18:47:44: PM2 log: App [Hyve:0] starting in -fork mode-
2021-02-22T18:47:44: PM2 log: App [Hyve:0] online
2021-02-22T18:48:15: PM2 log: Stopping app:Hyve id:0
2021-02-22T18:48:15: PM2 log: App [Hyve:0] exited with code [0] via signal [SIGINT]
2021-02-22T18:48:15: PM2 log: pid=21684 msg=process killed
2021-02-22T18:48:46: PM2 log: App [Hyve:0] starting in -fork mode-
2021-02-22T18:48:46: PM2 log: App [Hyve:0] online
2021-02-22T18:48:46: PM2 log: App [Hyve:0] exited with code [1] via signal [SIGINT]
// OS Info
$ lsb_release -a
Distributor ID: Pop
Description: Pop!_OS 20.10
Release: 20.10
Codename: groovy
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the shown process.json using ignore_watch, then run pm2-dev start process.json --ignore with both uploads and downloads. Trace how these options are parsed and passed to the watcher; done means both directories are ignored and file changes there no longer restart the application.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100