2

I have a post-receive hook written in python, whose main function is to deploy the updated branch. It clones the repo into a new dir, and runs environment setups like npm install and building/populating virtualenvs. This runs on the server side, and is triggered by pushes to git-http-backend (proxied behind nginx).

This deploy takes some time— several minutes. This seems to be too much for git, which concludes that The remote end hung up unexpectedly and it delivers an error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out.

I have found this answer which concluded that git gives up if there is no output to stdout for awhile. The poster "fixed" the problem by making his script spam more output to stdout. That's not ideal for me. Is there a way to configure git so that it doesn't give up after a short timeout?

I also notice that I don't see any output on the client side until the script is complete. It would be better if the user got feedback as the script progressed. Is there a way to get "live" output from the hook scripts?

In fact, am I even going about this the right way? What is the "proper" way to have long-running scripts that run as the result of git hooks, where the user needs to see feedback (i.e. output/results)?

EDIT: Further investigation turned up the fastcgi_read_timeout setting for nginx. This can be increased for longer timeouts— but it doesn't fix my problem. After redirecting stdout to file, I find that my script actually completes quite quickly. But for some reason the git backend doesn't pass along stdout when it's there, and then hangs forever. Also, redirecting stdout fixes the hang. What's going on?

EDIT2: Further debugging has revealed that the script fails while contacting the same git server to clone a different repo (the server returns 504 there too). This seems to suggest that git-http-backend can only handle one request at the time? Is it failing because the post-receive is still in progress when this new clone request comes in? If so, that seems alarmingly limiting! Is there a way to support simultaneous requests to git-http-backend?

trbabb
  • 131
  • 3

0 Answers0