Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autostart = false prevents apps from being started #5840

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/God.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ God.executeApp = function executeApp(env, cb) {
* 2 - Reset restart time and unstable_restarts
* 3 - Assign a log file name depending on the id
* 4 - If watch option is set, look for changes
* 5 - If autostart option is false, skip process start
*/
if (env_copy['pm_id'] === undefined) {
env_copy['pm_id'] = God.getNewId();
Expand All @@ -207,16 +208,16 @@ God.executeApp = function executeApp(env, cb) {
if (env_copy['watch']) {
God.watch.enable(env_copy);
}

if (!env_copy['autostart']) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a somewhat breaking change of default behaviour to change env_copy['autostart'] === false to !env_copy['autostart'], meaning if the user does not specify the autostart field, i.e. env_copy['autostart'] === undefined, previously it will auto start, but now it will no longer auto start

Copy link

@noelzubin noelzubin Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure, but looks like the value for autorestart defaults to true if not set in the client signal.

pm2/lib/API.js

Line 681 in 87612eb

var app_conf = Config.filterOptions(opts);

pm2/lib/API.js

Line 879 in 87612eb

that.Client.executeRemote('prepare', resolved_paths, function(err, data) {

@lvlingxiao1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not entirely sure either, looks like the filterOptions method just filters out all the options that do not exist in the schema, I don't see any default values though, I think the default is just undefined

Copy link

@noelzubin noelzubin Jul 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh my bad. I meant to link this .

pm2/lib/API.js

Line 701 in 87612eb

if ((appConf = Common.verifyConfs(app_conf)) instanceof Error) {

Common.verifyConfs(app_confi) @ lib/API.js:701
Config.validateJSON(app) @ lib/Common.js:850
res[sk] = defines[sk].default @ lib/tools/Config.js:114

var clu = {pm2_env: env_copy, process: {pid: 0}};
God.clusters_db[env_copy.pm_id] = clu;
return cb(null, clu);
}
}

God.registerCron(env_copy)

if (env_copy['autostart'] === false) {
var clu = {pm2_env: env_copy, process: {pid: 0}};
God.clusters_db[env_copy.pm_id] = clu;
return cb(null, clu);
}

/** Callback when application is launched */
var readyCb = function ready(proc) {
// If vizion enabled run versioning retrieval system
Expand Down