ColemanGariety / gulp-nodemon

gulp + nodemon + convenience
526 stars 76 forks source link

using --inspect crashes on restart #139

Open andrewgbliss opened 7 years ago

andrewgbliss commented 7 years ago

Here is my nodemon gulpfile. I am running the process in a docker container.

gulp.task('start:dev', done => {
  let started = false;
  nodemon({
    script: path.join(__dirname, 'index.js'),
    ext: 'js json',
    nodeArgs: ['--inspect=0.0.0.0:9229'],
    watch: path.join(__dirname, 'express'),
    legacyWatch: true,
    delay: 2000
  })
  .on('start', () => {
    // to avoid nodemon being started multiple times
    if (!started) {
      setTimeout(() => done(), 100);
      started = true;
    }
  });
});

Every time I save a file nodemon restarts as it normally would. But it also crashes with this error message:

Starting inspector on 0.0.0.0:9229 failed: address already in use app crashed - waiting for file changes before starting...

If I then save the file again it restarts it just fine. Is there a way to wait for the 9229 port to release before it starts again? It's really annoying to save a file twice just to get it to work.

If I change it to --debug it works, but that is deprecated. They want everyone to use --inspect.

rluncasu commented 7 years ago

Same here, I'm starting it with

nodemon --inspect=0.0.0.0:9229 /app/server.js

inside a container based on

FROM node:8.1.0

with a shared volume on sources. Whenever I save a file on the sources volume, nodemon restarts but crashes with

[nodemon] restarting due to changes...
  nodemon bus emit: restart +13s
  nodemon bus.emit(exit) via SIGUSR2 +14ms
  nodemon bus emit: exit +0ms
[nodemon] starting `node --inspect=0.0.0.0:9229 /app/server.js`
  nodemon spawning node --inspect=0.0.0.0:9229 /app/server.js +1ms
  nodemon bus emit: start +7ms
  nodemon bus new listener: exit (1) +1ms
  nodemon start watch on: *.* +0ms
  nodemon:watch early exit on watch, still watching (1) +1ms
Starting inspector on 0.0.0.0:9229 failed: address already in use
[nodemon] app crashed - waiting for file changes before starting...

Re-saving the same file, again restarts but works ok this time. I'm NOT using gulp-nodemon...just accidentally got here when searching for the issue. Seems to be an issue with nodemon itself.

megakoresh commented 7 years ago

Yeah same problem, using sails here + nodemon. Doing the following: nodemon --inspect app.js produces error: Gulp :: Starting inspector on 127.0.0.1:9229 failed: address already in use As the error shows up before any tasks are even attempted, I think this must be a deeper issue, potentiallu with gulp itself.

yujiahaol68 commented 7 years ago

Just kill inspector and start inspector again here is our team's solution in our package.json The same in gulp task. You have to kill it first..

npm install --save-dev kill-port

in your package.json file. Kill it first before you run debug inspector on the same port.

"inspect": "kill-port --port 9229 && node --inspect=0.0.0.0:9229 build/startup.js",
"start_watch_inspect": "nodemon --delay 80ms --watch build/ build/startup.js --exec 'npm run inspect'",
poonam-dev commented 7 years ago

error

please solve this

yujiahaol68 commented 7 years ago

Please try not to use nodemon to enable debug mode. Try to use node --inspect=...

poonam-dev commented 7 years ago

error1

now generate this error

poonam-dev commented 7 years ago

for put node --inspect=... at the place of nodemon --debug

peeyushsrivastava commented 6 years ago

Try this approach may be it helps.

Actually it's getting started in background so you need to search for process which you have tried to run with command like nodemon --inspect app.js , so check if node server is running or not.

ps ax | grep node

then killall -9 node and then try this command and it will work.

wzup commented 6 years ago

@yujiahaol68

kill-port: command not found

yujiahaol68 commented 6 years ago

@wzup Please install kill-port as dev npm package first and then you can use it in your package.json script

Robinfr commented 6 years ago

No solution for this? It's really annoying as you don't even get output anymore when it fails..

SenP commented 5 years ago

This seems to be an irritating bug with no clear solution yet