Nodejs forked child process exits immediately from status code 8

I start the child process and for some odd reason every time the child exits with a status code of 8 . I've done a bunch of googling trying to figure out what status code 8 is and what might be causing this strange behavior in Ubuntu, but no luck. I found out that Node.js doesn't even use exit status code 8, so I'm pretty sure it's not V8. I tried running the same code on a different but identical Ubuntu server and it worked fine. Just to note that I am using load balancing on this server. I'm not sure what might be causing this problem.

Here are the specs:

  • Node: v0.10.25
  • Distributor ID: Ubuntu
  • Description: Ubuntu 14.04
  • LTS Release: 14.04

This is a forked child process (as I said, its minimum level)

    process.on ('message', function (data) {
        console.log ('TEST BOT SAYS HELLO' + process.pid)

        var fs = require ('fs')
        fs.writeFile ('message.txt', 'abc', function (err, data) {
            if (err) {
                return console.log (err);
            }
            console.log (data);
        });

    });

Edit: There is no other error in the stack trace. Any hints to figure this out will help!

This is how the child process starts:


        function testChildProcess () {
            console.log ('testing child process')
            var testBot = childProcess.fork (require.resolve ("./../../ bots / testBot"));

            testBot.send ({
                data: 'hello'
            });

            testBot.on ('exit', function (code, other) {
                console.log ('Child process exited with exit code' + code + 'other');

            });
            testBot.on ('error', function (code) {
                console.log ('Child process ERRED with exit code' + code);
                return nextTracker ();
            });
        }
    testChildProcess ()

Addendum: The app is launched using https://github.com/yyx990803/pod which uses pm2 in the background

https://github.com/Unitech/pm2 to run your app as a daemon.

I've tested the spawning child process and the spawning child process works fine ...

child.js

    var test = function () {
        console.log ('TEST BOT SAYS HELLO' + process.pid)

        var fs = require ('fs')
        fs.writeFile ('./ message.txt', 'abc', function (err, data) {
            if (err) {
                return console.log (err);
            }
            console.log (data);
        });

    }
    test ();

parent.js


function testChildProcess () {
console.log (process.cwd ());

        var ls = childProcess.exec ('node' + process.cwd () + '/ bots / testBot', function (error, stdout, stderr) {
            if (error) {
                console.log (error.stack);
                console.log ('Error code:' + error.code);
                console.log ('Signal received:' + error.signal);
            }
            console.log ('stdout:' + stdout);
            console.log ('stderr:' + stderr);

        });

        ls.on ('exit', function (code) {
            console.log ('Child process exited with exit code' + code);
        });
    }

SOLUTION: If someone else gets this problem. I managed to get by by establishing silence.

var testBot = childProcess.fork (require.resolve ("./../../ bots / testBot"), [], {silent: true});


+3


source to share


1 answer


SOLUTION: If anyone else gets this problem, I managed to get around by setting silent

to true.



var testBot = childProcess.fork(require.resolve("./../../bots/testBot"),[],{silent:true});

      

-1


source







All Articles