Unitech / Unitech/pm2

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

Open
#6,016 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

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?

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

Start with the reported index.js reproduction and the pm2.start(p) entry point, then trace how the child process receives cron_restart from the root process. Reproduce the behavior with the supplied configurations and verify that a child started in the same namespace no longer inherits the root schedule when its own setting disables it.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.