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

Can't start app when using autostart = false #5831

Open
jjensenbloom opened this issue May 28, 2024 · 5 comments
Open

Can't start app when using autostart = false #5831

jjensenbloom opened this issue May 28, 2024 · 5 comments

Comments

@jjensenbloom
Copy link

What's going wrong?

I can't start any apps when using the 'autostart' parameter

How could we reproduce this issue?

ecosystem.config.js

module.exports = [{
  name: 'testapp',
  script: `test.js`,
  autostart: false
}];

test.js

console.log('Hello World!');

Supporting information

# Run the following commands
$ pm2 start ecosystem.config.js
$ pm2 start testapp
$ pm2 logs testapp
# Logs are empty

I made a PR to fix this in the forked repo but it didn't get merged: ultimate-tester#1

@dimitriaatos
Copy link

dimitriaatos commented May 29, 2024

I can reproduce the issue.

Why don't you make a PR to pm2 directly?

@Vincent-SV
Copy link

From what I understand, autostart: false is for adding the app to the pm2 list as "stopped" so it makes sense it does not run.
I didn't find any documentation on it though (the closest is this : #5782).
Maybe there is some confusion with autorestart ?

On the other hand, I thought it was useful to get a cron task running without the initial run off-schedule, but the app does not run at all when using cron_restart: "* * * * *" and autostart: false

@dimitriaatos
Copy link

dimitriaatos commented May 31, 2024

The issue is that, if pm2 is started with autostart false, the app won't start after even with pm2 start app or pm2 restart app.

For example, running the following

pm2 start --no-autostart app.js
pm2 start app
pm2 ls

gives

┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0  │ app                │ fork     │ 0    │ stopped   │ 0%       │ 0b       │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

The same happens if autostart: false is set in ecosystem.config.js.

@Vincent-SV
Copy link

I thought this was expected behaviour, and that the point of it was that only cron_restart could start the app.
But cron-restart can't start the app either so you are probably right. (oh, and I just understood that you are a regular contributor)

The lack of documentation makes it difficult to talk about this, the expected behaviour is unclear to me.

@dimitriaatos
Copy link

Related issue about --cron-restart #5807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants