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

using --inspect crashes on restart

Open andrewgbliss opened this issue 8 years ago • 12 comments
trafficstars

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.

andrewgbliss avatar Apr 26 '17 15:04 andrewgbliss

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.

rluncasu avatar Jun 15 '17 09:06 rluncasu

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.

megakoresh avatar Jul 28 '17 09:07 megakoresh

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'",

yujiahaol68 avatar Aug 21 '17 08:08 yujiahaol68

error

please solve this

poonam-dev avatar Aug 30 '17 13:08 poonam-dev

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

yujiahaol68 avatar Aug 30 '17 13:08 yujiahaol68

error1

now generate this error

poonam-dev avatar Aug 30 '17 14:08 poonam-dev

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

poonam-dev avatar Aug 30 '17 14:08 poonam-dev

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.

peeyushsrivastava avatar Apr 02 '18 06:04 peeyushsrivastava

@yujiahaol68

kill-port: command not found

wzup avatar May 06 '18 13:05 wzup

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

yujiahaol68 avatar May 08 '18 01:05 yujiahaol68

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

Robinfr avatar Jun 18 '18 09:06 Robinfr

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

SenP avatar Oct 04 '18 01:10 SenP