nodejs won't stay running

153 views
Skip to first unread message

J

unread,
Mar 9, 2011, 9:48:12 PM3/9/11
to nodejs
I don't know how to "keep" nodejs running. I have a pretty simple
script using websocket-server and some mosquitto_sub's inside the .js.

IF I run it like this: node node.js

...Everything is fine for like 60 minutes, then it just crashes
without any great error message.

IF I run it: nohup node.js & ...It crashes in 10 minutes

IF I run it using "forever" (the program)...it crashes in about 10
minutes.

I haven't tried "upstart" because it isn't compiling (requires like a
spaceshuttle work of libraries and stuff).

Any ideas? Thank you very much.

Joe

Marak Squires

unread,
Mar 9, 2011, 9:55:52 PM3/9/11
to nod...@googlegroups.com, J
Forever can restart your process if it fails. If your app crashes after 10 minutes, Forever should restart it every 10 minutes. Is Forever not restarting your app?

You should ask yourself why your application is crashing in the first place. No matter what your solution is for keeping a node process up, it the application crashes by design every 10 minutes you've probably done something very wrong.

What is the error causing the crash? Are you not catching something? Do you know how to use the uncaught exception handler? 


--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Tim Caswell

unread,
Mar 9, 2011, 9:57:04 PM3/9/11
to nod...@googlegroups.com
I would recommend upstart if you already have it (like on an ubuntu server for example), but for testing, just use a while true loop in bash that runs your server over and over.  That just fixes the symptom though.  The real question is why is your server crashing after a while?

On Wed, Mar 9, 2011 at 6:48 PM, J <command...@gmail.com> wrote:

Ryan Dahl

unread,
Mar 9, 2011, 10:07:35 PM3/9/11
to nod...@googlegroups.com, J
On Wed, Mar 9, 2011 at 6:48 PM, J <command...@gmail.com> wrote:

Sounds like it's segfaulting - would be nice to get a stacktrace or coredump.

Taylor Buley

unread,
Mar 9, 2011, 10:25:09 PM3/9/11
to nod...@googlegroups.com
> You should ask yourself why your application is crashing in the first place.

When starting with Node I was surprised to read that the default
behavior for an uncaught exception was to print a stack trace and
exit.

It can be helpful to catch any Exceptions you might have missed with
something like:

xxx
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});

xxx

via http://nodejs.org/docs/v0.4.2/api/all.html#event_uncaughtException_

On Wed, Mar 9, 2011 at 6:55 PM, Marak Squires <marak....@gmail.com> wrote:
> Forever can restart your process if it fails. If your app crashes after 10
> minutes, Forever should restart it every 10 minutes. Is Forever not
> restarting your app?

CalliNode

unread,
Mar 10, 2011, 2:08:04 PM3/10/11
to nodejs
My NodeJS-App also crashed every 15 minutes with an "out of memory"
error.

The App is pretty simple, like the "hello world" example on the
nodejs.org. But NodeJS can´t handle so many requests during an DDoS,
so I used http://learnboost.github.com/cluster/ and with 4 worker, no
more "out of memory".
Reply all
Reply to author
Forward
0 new messages