xolvio / qualityfaster

An example project showing how to create robust and maintainable acceptance tests
262 stars 58 forks source link

Chimp process not killed in process close event #4

Closed kristijanhusak closed 3 years ago

kristijanhusak commented 8 years ago

Hi,

I cannot manage to run CI=1 npm start twice in my local environment. I get this error:

> @ start /home/kristijan/code/meteor-tests
> .scripts/start.js

Can't listen on port 3000. Perhaps another Meteor is running?

Running two copies of Meteor in the same application directory
will not work. If something else is using port 3000, you can
specify an alternative port with --port <port>.
Meteor App exited with code 254

npm ERR! Linux 4.2.0-22-generic
npm ERR! argv "/home/kristijan/.nvm/versions/node/v5.3.0/bin/node" "/home/kristijan/.nvm/versions/node/v5.3.0/bin/npm" "start"
npm ERR! node v5.3.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! @ start: `.scripts/start.js`
npm ERR! Exit status 254
npm ERR! 
npm ERR! Failed at the @ start script '.scripts/start.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     .scripts/start.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/kristijan/code/meteor-tests/npm-debug.log

I noticed that chimp process is not killed in the close event here, only the meteor app is killed. I had to run kill -9 pid to kill the chimp process. Is there a way to fix this?

When I run only npm start and kill watch process, I can rerun it without any problem.

OS: Xubuntu 15.10 64 bit node: v5.3.0 npm: 3.3.12

samhatoum commented 8 years ago

Hmm, might be a linux issue. I just tried it on OSX and works. I'll try on linux soon.

workflow commented 8 years ago

Can confirm this is happening on the following architecture as well:

OS: Ubuntu 14.04 64 bit node: v5.2.0 npm: 3.3.12

kristijanhusak commented 8 years ago

I researched a little bit more, and noticed that the problem is with the Meteor app that is started, not the Chimp. So when app is started here, it only runs meteor command, which later spawns it's own child processes. Killing this process does not kill those meteor child processes. For now, only solution I found is to kill all meteor processes in process close event:

  proc.on('close', function (code) {
    console.log(opts.name, 'exited with code ' + code);
    for (var i = 0; i < processes.length; i += 1) {
      processes[i].kill();
    }
    // Kill all meteor processes
    exec('kill `ps ax | grep node | grep meteor | awk \'{print $1}\'`');
    process.exit(code);
  });
samhatoum commented 8 years ago

Thank you for doing the research

Another place you can add the kill in the meantime is to put it here

Something like:

"test": "kill `ps ax | grep node | grep meteor | awk \'{print $1}\'` && .scripts/test.js"
shrop commented 8 years ago

I am seeing the same issue with npm test

I did the following $ watch -n 1 "ps auxww" In another tmux pane $ npm test Tests started, I noticed the meteor process fire up, tests ended, but the meteor process never terminates.