Deploying Node.js with systemd
savanne.be
savanne.be
The solution to that in the article seems an awful lot of trouble. You can just use the following in your script to keep it from crashing/exiting whenever there's an exception, warning or whichever:
process.on('uncaughtException', function (err) { //do stuff });
I've used that in a few projects, where it usually sends me an email if something goes wrong. (npm: mailer).
Just keeping it running isn't the main point though: socket activation is great if you want to increase server density. And the whole-system monitoring + resource policies are very nice tools for system administrators.
There's a lot more to systemd and node.js than simply running node.
If you are currently running Ubuntu and use upstart, by all means leave it like that: don't fix it if it ain't broken.
But do know that you miss out on some very nice things :-)
Originally we did just purely use upstart to control things but it was pretty dreadful at doing certain things compared to monit, and we have a lot of familiarity with monit from our embedded hardware projects.
monit is great because you can get emails if your app goes down, it monitors files and all kinds of other stuff. you could easily use socket activation with monit so that a crashing node process drops as few connections as possible by passing along the fd to another node process, but then if you are going to do this you might as well use cluster and fork your node process.
tldr; many ways to skin a cat, but turning off your node process because it is idle is kind of weird because it has implications for the first visitor, and it shouldnt just be reached for as a standard way of running node
For large node programs, this approach may require careful optimization of the start process in the same way that we optimize the client-side page loading process.
There's a lot of great documentation on the systemd site. An exact description of socket activation and its intended use cases is on there as well: this is definitely one of them.