Svn – Running Subversion post-commit hook as a background process

background-processsvn

Because currently our Subversion post-commit hooks take way too long to execute I've been trying to speed things up.

I've been thinking about executing the actual hooks as a background process, so that the svn commit would complete before the actual hooks finish running.

So I created two files.

A post-commit.bg that does something time-consuming:

sleep 10

And the actual post-commit itself that executes the former in background:

bash post-commit.bg &

When I run post-commit from command line it finishes quickly, leaving post-commit.bg still running. But when I do svn commit it still takes 10 seconds!

Are background processes somehow disallowed by SVN or what could I be doing wrong here?

Best Answer

I just confirmed this locally. It appears to be by design:

When running hooks, svn calls apr_proc_wait

apr_proc_wait is designed to wait until all child processes exit before returning. This is to avoid zombie(unowned) processes overrunning the system.

You might have some success if you find a way to detach the process (ie, daemon mode), but I'm not sure.

You might find it better to run another process somewhere which does some work in response to a ping from svn - Hudson is my choice for this sort of thing - jobs can be triggered by a wget in a post-commit hook, or you can have it poll subversion for you, depending on what you want to do.

Related Topic