Hacker News new | ask | show | jobs
by jaysylvester 611 days ago
That's a fair observation. I only include it because the Node way of doing things seems to be "just let the process crash and restart it", and that's been a tough concept for me to accept. I'm particularly proud of error handling in citizen and want it to be as much like an old-school app server as possible.

I still use pm2 on the aforementioned site just in case though, and maybe seeing that extended process uptime is just a feel-good exercise, but still worth mentioning.

I've been meaning to do real performance testing and keep pushing it off because it's been adequate for my needs.

1 comments

> the Node way of doing things seems to be "just let the process crash and restart it"

Honestly I've never heard of anyone advocating for this.

PM2 is only necessary if you're running Node in like a VPS where you're in charge of managing the process. In managed solutions like Fly, Google Cloud Run, etc you never really have to care about this. VMs are restarted automatically and it's trivial to have HA with multiple VMs running in parallel.

The scenario you described is exactly how I host my sites now (Debian on DO).

I've seen numerous engineers advocate for letting the app crash (or at least gracefully shutting it down), capturing the error, and restarting. Errors crash the Node process by design after all. Perhaps it's not as prevalent as it used to be, but it was certainly considered acceptable and even desirable for a time to let the app crash and restart it with pm2, forever, etc. since an error could leave the app in an unknown state.

citizen has a config option for keeping the app running or exiting the process in the event of an error, so it's up to the dev.