2

I've started a NodeJS process on Linux server by this:

nohup node server.js

It's weird that a couple hours later, this process will be killed, I don't why.

UPDATE

I monitored the CPU/Memory usage, it looks good, memory is enough. Here how I create my NodeJS server:

// start server
process.on('uncaughtException', function (ex) {
    console.log("uncaught exception : ")
    console.log(ex)
});

var server = app.listen(config.port, function () {
    var host = server.address().address
    var port = server.address().port
    console.log("your server is listening at http://%s:%s", host, port)
})

Start Command:

[localhost]$ nohup node server.js > log.txt 2>&1 &

Still, The process has been killed without any exception output.

Is there any method that can let me know what's going on here ?

WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138
  • Yes, that's certainly possible (it's called the [_OOM Killer_](https://linux-mm.org/OOM_Killer)). You should be able to find a log entry about that in the output of the `dmesg` command, or in `/var/log/syslog`. – robertklep Mar 10 '17 at 12:39
  • @robertklep thanks, I've checked the memory usage, it look fine, enough memory there. – WoooHaaaa Mar 11 '17 at 05:25
  • Start your node application in foreground under the `gdb` debugger? It may print cause of debugged process termination. What is work done by server, are there many clients? Do you open many files or create many threads? Is there any other resource exhaustion, like fd (file descriptor) leak, lot of used vmas or limited pid (by default linux allow no more 65k pids - http://stackoverflow.com/questions/5635362/max-thread-per-process-in-linux) or any other `ulimit` acted? – osgx Mar 11 '17 at 05:32
  • @osgx I just set `ulimit -c` to `unlimited`, waiting for another crash... – WoooHaaaa Mar 11 '17 at 05:43

1 Answers1

0

Use 'setInterval' function, 'console.log' anything you want, and the system would not kill your server again.

SetupX
  • 413
  • 2
  • 5
  • 13