Skip to content

Loading…

Respond to 'close' event rather than 'exit' on newer nodes #8

Open
wants to merge 2 commits into from

3 participants

@isaacs

In node 0.6 and before, the semantics around the child process 'exit' even were a bit screwey. Even after the child process had actually exited, it would delay until the stdout and stderr had closed before emitting the exit event.

This was especially problematic when sharing FDs with the parent process, since the stdout and stderr would never close, and there was no way to know when the child was done with them.

For 0.8 and above, we've changed this. Now, 'exit' means 'the child process has exited' and the 'close' event means 'the output is done'. For pushover, this means that we need to listen for the close event, since that is when all the output from git is actually done.

isaacs added some commits
@isaacs isaacs Listen for 'close' event on node >=0.7.x 785d5d9
@isaacs isaacs Prefer 'git service' rather than 'git-service'
The git-foo scripts are internal API to git, and on windows, they
are not exposed.
cf2b33b
@machadogj

On windows 7 spawn('git', [..... is failing because it can't find "git". Isn't something like this necessary?

var gitCommand = require('which').sync('git');
@martindale

I presume this is rendered irrelevant with #19?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 27, 2012
  1. @isaacs
Commits on May 29, 2012
  1. @isaacs

    Prefer 'git service' rather than 'git-service'

    isaacs committed
    The git-foo scripts are internal API to git, and on windows, they
    are not exposed.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 3 deletions.
  1. +7 −3 index.js
View
10 index.js
@@ -163,7 +163,8 @@ Git.prototype.handle = function (req, res, next) {
);
noCache();
- var ps = spawn('git-' + service, [
+ var ps = spawn('git', [
+ service,
'--stateless-rpc',
repopath,
]);
@@ -204,12 +205,15 @@ function serviceRespond (service, file, res) {
res.write(pack('# service=git-' + service + '\n'));
res.write('0000');
- var ps = spawn('git-' + service, [
+ var ps = spawn('git', [
+ service,
'--stateless-rpc',
'--advertise-refs',
file
]);
ps.stdout.pipe(res, { end : false });
ps.stderr.pipe(res, { end : false });
- ps.on('exit', function () { res.end() });
+ var ev = 'close';
+ if (process.version.match(/^v0\.[0-6]\./)) ev = 'exit';
+ ps.on(ev, function () { res.end() });
}
Something went wrong with that request. Please try again.