PM2 cannot start my Angular app while ng serve (run) do
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
Hello,
I just try to deploy my angular app V13 with the tool pm2. everything was going well until i tried to setup my certificate and deploy ssl for https.
How could we reproduce this issue?
I setup the package.json
ng run <myproject>:serve-zip --configuration production --host 0.0.0.0 --disable-host-check --ssl
and the angular.json
"serve-zip": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "e-learning:build-zip:production",
"ssl": true,
"sslKey": "./ssl/server.key",
"sslCert": "./ssl/server.crt",
"publicHost":":4200"
},
"configurations": {
"production": {
"browserTarget": ":build-zip:production"
},
"development": {
"browserTarget": ":build-zip:development"
}
},
"defaultConfiguration": "production"
},
Supporting information
When i launch with the command ng run directly everything is ok but when i use pm2 start i got this error
5|pl-front | const address = devServer.server.address();
5|pl-front | ^
5|pl-front | TypeError: Cannot read properties of undefined (reading 'address')```
<!--
Please run the following command (available on PM2 >= 2.6)
-->
$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date : Thu Jun 23 2022 14:33:17 GMT+0100 (West Africa Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.1.2
node version : 16.15.0
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : root
uid : 0
gid : 0
uptime : 14545min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.1.2
node version : 16.15.0
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/bin/pm2,report
argv0 : node
user : root
uid : 0
gid : 0
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
cpus nb : 4
freemem : 6145499136
totalmem : 8348454912
home : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 2 │ xxxxxx-git │ default │ N/A │ fork │ 2878 │ 10D │ 0 │ online │ 0.3% │ 63.4mb │ root │ disabled │
│ 1 │ xxxxx1-git │ default │ N/A │ fork │ 255836 │ 7D │ 1 │ online │ 0.2% │ 61.0mb │ root │ disabled │
│ 9 │ xxxxx2-git │ default │ N/A │ fork │ 1004068 │ 6s │ 510 │ online │ 0% │ 61.9mb │ root │ disabled │
└─────┴──────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2 | 2022-06-23T14:32:32: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:32:32: PM2 log: App [pl-frontend-git:9] online
PM2 | 2022-06-23T14:32:38: PM2 log: App [pl-frontend-git:9] exited with code [1] via signal [SIGINT]
PM2 | 2022-06-23T14:32:38: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:32:38: PM2 log: App [pl-frontend-git:9] online
PM2 | 2022-06-23T14:32:45: PM2 log: App [pl-frontend-git:9] exited with code [1] via signal [SIGINT]
PM2 | 2022-06-23T14:32:45: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:32:45: PM2 log: App [pl-frontend-git:9] online
PM2 | 2022-06-23T14:32:51: PM2 log: App [pl-frontend-git:9] exited with code [1] via signal [SIGINT]
PM2 | 2022-06-23T14:32:51: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:32:51: PM2 log: App [pl-frontend-git:9] online
PM2 | 2022-06-23T14:32:57: PM2 log: App [pl-frontend-git:9] exited with code [1] via signal [SIGINT]
PM2 | 2022-06-23T14:32:57: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:32:57: PM2 log: App [pl-frontend-git:9] online
PM2 | 2022-06-23T14:33:04: PM2 log: App [pl-frontend-git:9] exited with code [1] via signal [SIGINT]
PM2 | 2022-06-23T14:33:04: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:33:04: PM2 log: App [pl-frontend-git:9] online
PM2 | 2022-06-23T14:33:11: PM2 log: App [pl-frontend-git:9] exited with code [1] via signal [SIGINT]
PM2 | 2022-06-23T14:33:11: PM2 log: App [pl-frontend-git:9] starting in -fork mode-
PM2 | 2022-06-23T14:33:11: PM2 log: App [pl-frontend-git:9] online
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the difference between running the Angular command directly and starting it with PM2, using the package.json and angular.json configuration shown. Inspect /node_modules/@angular-devkit/build-webpack/src/webpack-dev-server/index.js around line 79 and review the PM2 report and restart logs. Done means the configured HTTPS Angular process starts under PM2 without the undefined address error or restart loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, node.js
- Domain
- cli, devops, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100