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) {