Repository navigation
Closed
Description
App, not running
pm2 start server.mjs success and shows online, but app not running on the port 4000
Supporting information
Angular Version 19.0.0
pm2 version 5.4.3
nodejs version 20.16.0
# Run the following commands
$ pm2 report
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.4.3
node version : 20.16.0
node path : /usr/local/bin/pm2
argv : /usr/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : root
uid : 0
gid : 0
uptime : 34min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.4.3
node version : 20.16.0
node path : /usr/local/bin/pm2
argv : /usr/bin/node,/usr/local/bin/pm2,report
argv0 : node
user : root
uid : 0
gid : 0
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : DO-Regular
cpus nb : 1
freemem : 179175424
totalmem : 479989760
home : /root
===============================================================================
PM2 | 2024-11-24T15:02:34: PM2 log: App [api:1] online
PM2 | 2024-11-24T15:08:06: PM2 log: Stopping app:server id:0
PM2 | 2024-11-24T15:08:06: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2 | 2024-11-24T15:08:06: PM2 log: pid=5503 msg=process killed
PM2 | 2024-11-24T15:08:49: PM2 log: App [server:2] starting in -fork mode-
PM2 | 2024-11-24T15:08:50: PM2 log: App [server:2] online
PM2 | 2024-11-24T15:12:54: PM2 log: Stopping app:server id:2
PM2 | 2024-11-24T15:12:54: PM2 log: App [server:2] exited with code [0] via signal [SIGINT]
PM2 | 2024-11-24T15:12:54: PM2 log: pid=5760 msg=process killed
PM2 | 2024-11-24T15:12:54: PM2 log: App [server:2] starting in -fork mode-
PM2 | 2024-11-24T15:12:54: PM2 log: App [server:2] online
PM2 | 2024-11-24T15:14:32: PM2 log: Stopping app:server id:2
PM2 | 2024-11-24T15:14:32: PM2 log: App [server:2] exited with code [0] via signal [SIGINT]
PM2 | 2024-11-24T15:14:32: PM2 log: pid=5845 msg=process killed
PM2 | 2024-11-24T15:15:12: PM2 log: App [server:3] starting in -cluster mode-
PM2 | 2024-11-24T15:15:12: PM2 log: App [server:3] online
PM2 | 2024-11-24T15:17:15: PM2 log: Stopping app:server id:3
PM2 | 2024-11-24T15:17:15: PM2 log: App name:server id:3 disconnected
PM2 | 2024-11-24T15:17:15: PM2 log: App [server:3] exited with code [0] via signal [SIGINT]
PM2 | 2024-11-24T15:17:16: PM2 log: pid=5964 msg=process killed
Reacted by Mehdi BENFREDJ
Metadata
Metadata
Assignees
Labels
No labels
Activity
MehdiBenfredj commentedon Feb 3, 2025
Hello, did you find any solution?
MehdiBenfredj commentedon Feb 3, 2025
Hi,
This should work ( it worked for me )
https://stackoverflow.com/questions/79214195/is-angular-19-0-incompatible-with-pm2
akilah007 commentedon Feb 4, 2025
MehdiBenfredj commentedon Feb 4, 2025
before:
after:
explanation:
"The isMainModule function comes from the @angular/ssr package and "Determines whether the provided URL represents the main entry point module." However, PM2 uses a container around the Node process to manage it (see pm2/lib/ProcessContainerFork.js). As a result, the function failed to determine that it's the main module who call it, the condition is never met, and the process stops there."
What you have to do instead is add a a another condition, that checks that is it being called by pm2 through an env variable. by adding the var to the
ecosystem.config.jsNext necessary steps:
-> create
ecosystm.config.js:-> make sure to launch from
ecosystem.config.js:pm2 start ecosystem.config.jsthis starts the server with the right env variables.
akilah007 commentedon Feb 5, 2025
niceilm commentedon Mar 13, 2025
Thanks a lot. it worked!
raouf-b-dev commentedon May 10, 2025
Thank you so much, even AI chatbots did not find the problem. Thank you very much.
And it's even well explained.
ManNQ-GSV commentedon Aug 7, 2025
Beautiful, many thanks