Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
binarykitchen opened this issue Jun 23, 2014 · 16 comments
Open

Comments

@binarykitchen
Copy link
Contributor

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
Copy link
Contributor Author

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)
    });
})

@ColemanGariety
Copy link
Owner

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
Copy link
Owner

@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.

@marvinroger
Copy link

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

@kweiberth
Copy link

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

@ColemanGariety
Copy link
Owner

@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.

@jakeorr
Copy link
Contributor

jakeorr commented Sep 22, 2015

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!

@kweiberth
Copy link

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

@marvinroger
Copy link

I can confirm the PR above is working fine.

@cgmartin
Copy link

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);

@Avcajaraville
Copy link

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

@kweiberth
Copy link

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

@adjavaherian
Copy link

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

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

@deterralba
Copy link

Same here, workaround still works.

@ColemanGariety
Copy link
Owner

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

@Ekimoth
Copy link

Ekimoth commented Nov 3, 2016

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.

@ColemanGariety ColemanGariety reopened this Nov 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants