gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85

803 views Asked by At

I'm running nodejs 0.12.3 - gulp 3.10.8 and Gulp-nodemon 2.0.3. gulpfile.js :

gulp.task('serve', ['build'], function() {
  gulp.start('fb-flo');
  nodemon({
    script:   paths.server,
    env:      { 'NODE_ENV': 'development' },
    // env: { 'NODE_ENV': 'production' },
    execMap:  {
      'js': 'node_modules/babel/bin/babel-node --stage 1' //ES7 cote server
    },
    delay:    '0ms',
    watch:    ['src/shared/', 'src/server/'],
    ignore:   ['src/shared/components'],
    tasks: function (changedFiles) {
      var tasks = [];
      changedFiles.forEach(function (file) {
        if (path.extname(file) === '.jsx' && !~tasks.indexOf('bundlejs')) tasks.push('bundlejs');
        if (path.extname(file) === '.less' && !~tasks.indexOf('compileless')) tasks.push('compileless');
      });
      return tasks;
    }
  }).on('exit', function(){
    //console.log(process._getActiveHandles());
    //console.log(process._getActiveRequests());
    process.once('SIGUSR2', function () {
      console.log('exit!...........');
      gracefulShutdown(function () {
        process.kill(process.pid, 'SIGUSR2');
      });
    });
  });
});

My server start well, but When I my server restarts after a change in js files in src/shared or src/server, I have the error :

[14:22:35] Finished 'default' after 4.4 μs
[14:22:35] [nodemon] exiting
events.js:85
  throw er; // Unhandled 'error' event
        ^
Error: listen EADDRINUSE

I understand that this mean that the adress is lareday in use, so as you can see I've tried to clean up when exiting through SIGUSR2 signal, but the console.log never get called... Any help would me appreciated ! Thanks

0

There are 0 answers