pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

cron_restart value is always inherited when I try to start another app in the same namespace programatically

Open twilson90 opened this issue 6 months ago • 2 comments

I have a pm2 process which is the 'root' that manages several other processes. It spawns the other processes under pm2

module.exports = {
	apps: [
		{
			name: `${appspace}.root`,
			namespace: appspace,
			script: "index.js",
			args: [],
			cron_restart: "0 5 * * Sun",
			exec_mode: 'fork',
			kill_timeout: 5000,
		},
	],
};

index.js:

let p = {
    "wait_ready": true,
    "namespace": this.appspace,
    "name": `${this.appspace}.${m}`,
    "script": run_path,
    "args": args,
    "node_args": node_args,
    "windowsHide": true,
    "max_restarts": 5,
    "autorestart": true,
    "restart_delay": 5000,
    "cron_restart" : "0" // trying to prevent inheriting
};
pm2.start(p);

No matter what I try, the other processes always inherits root's cron_restart value. The root process handles all exit signals and closes the pm2 processes in the same appspace. Although it does no harm to close the other processes at the same time as the root, it's just not desirable. Seems like a bug. How do I prevent pm2 assigning the same cron_restart value as root?

twilson90 avatar Jul 19 '25 18:07 twilson90

bump

This is still an issue and causing problems on my end.

twilson90 avatar Aug 10 '25 11:08 twilson90

same here

Mizumaki avatar Sep 10 '25 08:09 Mizumaki