Sooo, this is a very simple solution that works for us for a single,
light-duty production server running at joyent. It solves problem 1 just
fine and problem 2 when the root cause is a bug in our app. It won't work
for big deployments, or for any server resource outage. I doubt many folks
who solve those problems at scale try to build identical systems that work
on both windows and nix.
We launch our production server using nodemon. We like nodemon because it
is small, simple, and reliable. Using nodemon as a process runner, most of
our server deployments are just git pulls.
Then we have a fancier version of this function in our main:
process.on('uncaughtException', function(err) {
// make sure you don't have a startup problem
require('fs').writeFileSync(__dirname + '/crash.js', err.stack||err)
// page the ops guys
process.exit(1)
}
On an uncaught exception, nodemon notices that the file crash.js changed
and bounces the node process, restarting the server in a stable state. We
originally held our nose writing this hack, planning to contract with some
monit guru to write a better solution, but it has worked so well that we
have become comfortable with it over time.
Again, not a real solution for high-scale production apps, but for all the
unwashed nodettes out there who value simplicity and want to sleep
peacefully with a single-box server, this works pretty well.
Cheers!
-george
On Saturday, January 12, 2013 3:17:08 PM UTC-8, nin jin wrote:
>
> Behaviour is similar, but different
> * Service runs with system privelegies. This is dangerous.
> * nssm is windows specific tool. Better to have one application stack on
> all platforms.
> * Аnyway someone must watch for files changes.
>
> 2013/1/13 José F. Romaniello <[email protected] <javascript:>>
>
>> I'd ask you the inverse, why would you reinvent the service function of
>> windows or *nix daemons in node? It's there, it is easy to use, the OS
>> comes with it. These things do a pretty good job starting the service when
>> booting, and trying to restart when it exist according the exit status.
>
>
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en