Unitech / Unitech/pm2

[Question] PM2 start and wait for http connection ready

Open
#4,967 0 comments 1 reaction 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

Hi,

I'm trying to use pm2 to start a react-app devServer with an npm script.
I would like PM2 to wait until the dev server is started.

I've tried to options of 'wait_ready' and 'listen_timeout', but PM2 keeps waiting for the complete timeout setting before continuing.

I'm not starting a webserver myself, react-app is responsible for that, so I cannot send 'ready' through process.send.

You documentation mentions "Graceful start using http.Server.listen", but how does this work, there are no examples. PM2 will not set the app as online when the application can be reached on port 3000.

Per my situation;

  • using pm2 to run npm start
  • I've set a listen_timeout of 60000 ms
  • the application is reachable after about 30 sec. (browser will load page)
  • PM2 keeps waiting the full 60 secs. before setting the app as "online"

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 documentation section titled "Graceful start using http.Server.listen" and review how wait_ready and listen_timeout are described. Reproduce the reported setup with PM2 running npm start and the application on port 3000, then document an example or clarify the expected readiness behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, react
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.