gulp-nodemon icon indicating copy to clipboard operation
gulp-nodemon copied to clipboard

Need to hit CTRL-C twice to abort it when it has restarted before

Open binarykitchen opened this issue 11 years ago • 16 comments

Yeah, this is weird. When no file has changed, I can cancel gulp with once CTRL-C.

But when nodemon has restarted due to a file change, then I have to hit CTRL-C twice to cancel gulp.

Something does not look right here ...

binarykitchen avatar Jun 23 '14 06:06 binarykitchen

Btw, this is my task:

gulp.task('run', ['default', 'watch'], function() {

    var nodemon = require('gulp-nodemon'),
        spawn   = require('child_process').spawn,
        bunyan

    nodemon({
        script: paths.server,
        ext:    'js json',
        ignore: [
            'var/',
            'node_modules/'
        ],
        watch:    [paths.etc, paths.src],
        stdout:   false,
        readable: false
    })
    .on('change', ['lint'])
    .on('readable', function() {

        // free memory
        bunyan && bunyan.kill()

        bunyan = spawn('./node_modules/bunyan/bin/bunyan', [
            '--output', 'short',
            '--color'
        ])

        bunyan.stdout.pipe(process.stdout)
        bunyan.stderr.pipe(process.stderr)

        this.stdout.pipe(bunyan.stdin)
        this.stderr.pipe(bunyan.stdin)
    });
})

binarykitchen avatar Jun 23 '14 06:06 binarykitchen

Yes, I've noticed this.

It has something to do with how nodemon gets handled under the hood, and is fundamental to gulp-nodemon's success. I'm going to put this on hold till a few other bugs in nodemon come around. Thanks for the documentation of this though!

ColemanGariety avatar Jun 24 '14 20:06 ColemanGariety

@binarykitchen I can no longer repro this; maybe it was fixed in a pull or with an update to nodemon? I'll leave this open for a bit so see if anyone is still seeing it.

ColemanGariety avatar Jan 07 '15 20:01 ColemanGariety

I do have the same issue... That's weird.

marvinroger avatar Sep 20 '15 11:09 marvinroger

Yeah I'm experiencing this as well. Using v2.0.4

kweiberth avatar Sep 22 '15 18:09 kweiberth

@kweiberth can anyone give me steps to reproduce? It does't seem to happen on my system. This is the most pervasive issue with the project at the moment so it needs a test.

ColemanGariety avatar Sep 22 '15 19:09 ColemanGariety

Hi Jackson, thanks for looking into this. I'm having to ctrl+c twice whenever I run my nodemon task.

The task:

var gulp = require('gulp'),
  nodemon = require('gulp-nodemon'),
  path = require('path');

gulp.task('nodemon', function () {
  nodemon({
      script: path.join(__dirname, '../../src/server/index.js'),
      ext: 'js',
      args: ['--color'],
      stdout: false
    });
});

The server:

'use strict';

var express = require('express');
var app = express();

app.get('/', function(req, res) {
  res.end('Hi');
});

app.listen(8080);

express: 4.13.3 gulp: 3.9.0 gulp-nodemon: 2.0.4 node: 4.0.0

Hopefully that helps!

jakeorr avatar Sep 22 '15 23:09 jakeorr

I'm encountering this problem when running gulp serve from the command line for this project: https://github.com/kweiberth/reedio-react

kweiberth avatar Sep 23 '15 04:09 kweiberth

I can confirm the PR above is working fine.

marvinroger avatar Oct 03 '15 16:10 marvinroger

I'm also encountering this issue using same versions as @jakeorr described, additionally with node: 4.2.1.

Currently using the following as a workaround in my Gulpfile, based on jake's PR:

// inside Gulpfile.js
function exitHandler() { process.exit(0); }
process.once('SIGINT', exitHandler);

cgmartin avatar Oct 30 '15 13:10 cgmartin

Im also having the same issue, @cgmartin workaround works for me

Avcajaraville avatar Nov 01 '15 15:11 Avcajaraville

I can also confirm that @cgmartin workaround works to overcome this issue for me.

kweiberth avatar Nov 06 '15 01:11 kweiberth

been looking high and low for this. Thanks @cgmartin!

//gulpfile.js
process.once('SIGINT', function(){
    process.exit(0);
});

adjavaherian avatar Nov 20 '15 20:11 adjavaherian

Same here, workaround still works.

deterralba avatar May 11 '16 02:05 deterralba

@deterralba is this issue present in latest gulp-nodemon? workaround has been merged.

ColemanGariety avatar May 11 '16 02:05 ColemanGariety

November 2016 and this issue with gulp-nodemon still hasn't been fixed. What I just found by accident is that when you give nodemon the tasks array parameter, not only does it run those tasks, but also reruns your gulpfile.js script with all of its tasks again. So if you modify a file 10 times, you would need to use Ctrl+C 10 times to terminate all gulp instances created by gulp-nodemon.

Ekimoth avatar Nov 03 '16 00:11 Ekimoth