pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

A stopped process doesn't watch anymore, if restarted

Open mschakulat opened this issue 9 years ago • 7 comments

I have the following config file:

` {

"apps": [
    {
        "name": "Repository",
        "script": "./bin/server.js",
        "exec_mode": "fork",
        "watch": "./restart_node",
        "watch_options": {
            "usePolling": true
        },
        "log_date_format": "YYYY-MM-DD HH:mm:ssZ",
        "error_file": "./logs/error.log",
        "out_file": "./logs/out.log",
        "merge_logs": true
    }
]

} `

Now i start the process like this:

pm2 start pm2.config.json

i get the following output:

[Watch] Start watching 45

Now i stop the process:

pm2 stop 45

This is the output:

[Watch] Stop watching 45

After i start again like above, there is no output which shows me, that watching is enabled and it doesn't watch anymore on my file. I also tried the restart command after stopping:

pm2 restart 45

which also didn't work. Is there anything more to do?

mschakulat avatar Jun 02 '17 14:06 mschakulat

Same problem here.

Just to mention that this problem only appears when I use a config file to launch my processes. If I just type pm2 start dist/bundle.js --watch then pm2 stop bundle then again pm2 start dist/bundle.js --watch the watching feature works as expected.

~~It also fails if I try to run it through a package.json script instruction as follow: "scripts": { "start": "pm2 start dist/bundle.js" }~~

EDITED: I obviously forgot to add the --watch option to my package.json script. It works as expected when launched from a npm script.

Ephasme avatar Jun 05 '17 16:06 Ephasme

Merging with https://github.com/Unitech/pm2/issues/2629

vmarchaud avatar Jun 07 '17 08:06 vmarchaud

It's still not working? :-1:

tsofist avatar Sep 27 '17 14:09 tsofist

+1 i restart config.js not working

busyhe avatar Nov 02 '17 02:11 busyhe

Same here. The only way I can stop and start a process and have it watch is to delete the process, then start a completely new one...

SamSverko avatar Sep 04 '19 14:09 SamSverko

Can this task be reopened? This is still happening in version 3.3.1

Gcuencam avatar Jun 25 '20 10:06 Gcuencam

This is still an issue. Even after I have deleted the process and restart it did not watch files and refer to old values from the file being watched. pm2 version 4.4.1

DishantPal avatar Sep 17 '20 11:09 DishantPal