From 6d39c65fb0842d8c365af64741502a3b599ff8a5 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 29 Sep 2025 17:04:54 +0900 Subject: [PATCH] fix(@schematics/angular): Out of the box support for PM2 Because PM2 is the most popular node process manager, it makes sense to support it out of the box. Fixes #31081 --- .../angular/ssr/files/application-builder/server.ts.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/schematics/angular/ssr/files/application-builder/server.ts.template b/packages/schematics/angular/ssr/files/application-builder/server.ts.template index 6fb8b2c77e5a..e7be03e005d9 100644 --- a/packages/schematics/angular/ssr/files/application-builder/server.ts.template +++ b/packages/schematics/angular/ssr/files/application-builder/server.ts.template @@ -48,10 +48,10 @@ app.use((req, res, next) => { }); /** - * Start the server if this module is the main entry point. + * Start the server if this module is the main entry point, or it is ran via PM2. * The server listens on the port defined by the `PORT` environment variable, or defaults to 4000. */ -if (isMainModule(import.meta.url)) { +if (isMainModule(import.meta.url) || process.env.pm_id) { const port = process.env['PORT'] || 4000; app.listen(port, (error) => { if (error) {