grunt-run icon indicating copy to clipboard operation
grunt-run copied to clipboard

Background process hangs when logging a lot

Open marcingrabda opened this issue 10 years ago • 5 comments

I am facing a strange issue.

I start java process using grunt-run plugin putting it into background ({wait: true}) passing control to another task which talks to the first one over http. The first one starts logging lots of messages after a while, which causes everything to hang.

If I decrease logging level, then everything works fine.

It seems like a bug to me.

Thanks, Marcin

marcingrabda avatar May 21 '15 23:05 marcingrabda

@marcingrabda yeah, the stdout queues can fill up after a while. If you're using the latest version it definitely is a bug

spalger avatar May 22 '15 00:05 spalger

Is there any workaround?

marcingrabda avatar May 22 '15 00:05 marcingrabda

Can you answer these please?

  1. What version of grunt-run are you using?
  2. What version of node are you using?
  3. What is the exact configuration you are using for grunt run?

spalger avatar May 22 '15 18:05 spalger

  1. grunt-run 0.3.0
  2. node 0.10.35 (tried also with 0.12.3)
  3. My configuration:
var grunt = require('grunt');

module.exports = {

    backend: {
        cmd: 'java',
        args: [
            '-jar',
            grunt.file.expand('../build/libs/*.jar')
        ],
        options: {
            wait: false,
            ready: /Tomcat started on port\(s\): 9000 \(http\)/
        }
    }
};

Adding {quiet: true} does not help.

marcingrabda avatar May 22 '15 18:05 marcingrabda

I'm starting this process as a first task in a series of tasks in grunt:

grunt.task.run(['run:backend', '...']);

I was investigating the issue, when I realized that once the run:backend task passes control to a next task, it stops logging (somehow it loses its ability to log) to stdout and this must be why it fills up its stdout buffer.

I'm not so familiar with streams in node.js, but it seems that in order to fix the issue, we need to redirect the stream somewhere. Additional piping, however, does not work.

marcingrabda avatar May 22 '15 23:05 marcingrabda