#Running SSR in pm2 doesn't work

4 messages · Page 1 of 1 (latest)

runic meteor
#

Not sure if this is a bug or what. I create a new app with SSR and SSG enabled. Changed nothing & built the app. Running directly against node the server works. Running under pm2 it just hangs and never opens the port. pm2 also doesn't detect it as crashed.

I've narrowed it down to line 56 of server.ts ```ts
if (isMainModule(import.meta.url))


isMainModule was added 4 months ago & checks if process.argv[1] equals the path to the complied server.mjs file. 
When running on node argv1 is: ```/var/www/domain.com/dist/app/server/server.mjs```
When running on pm2 argv1 is: ```/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js```

Is anyone else using the latest angular version with SSR enabled and using pm2 to run the server having this issue? For now I'm just going to remove the  isMainModule check.
runic meteor
#

After removing the check for isMainModule I can now run in pm2 but ng serve no longer works. After making a change and angular complies I am hit with this error

Error: listen EADDRINUSE: address already in use :::4008

Seems like it isn't killing the server and is trying to start a new instance.

grave birch
#

The isMainModule check prevents server.ts from starting the actual server in dev mode.

#

So now that you have removed it, the dev server can no longer start, because it's loading server.ts and that already opens the port (or vice versa).