On Thu, 9 Feb 2006, Kalin KOZHUHAROV wrote:
> Ryan Schmidt wrote:
> >
> > On Feb 8, 2006, at 22:10, Josh Kuo wrote:
> >
> > Ah, now this topic is interesting to me. For the longest time I've
> > wanted to spawn off a process in a post-commit hook to do some extra
> > work after the commit is done, without making the client wait for it,
> > but I never got around to trying it. Well thanks to this thread, now I
> > have, and I also can't get the post-commit hook to relinquish control
> > back to the client until the spawned process is completed.
> >
> > My repository is in /tmp/repo. Here's the post-commit hook:
> >
> > #!/bin/sh
> >
> > REPO="$1"
> > REV="$2"
> >
> > /tmp/repo/hooks/countdown.sh "${REPO}" "${REV}" >/dev/null 2>&1 &
>
> Try to close the STDIN as well? Disclaimer: I didn't.
>
> /tmp/repo/hooks/countdown.sh "${REPO}" "${REV}" &>/dev/null </dev/null &
>
> Whenever I spawn a remote process via SSH, I need to do this in order to be
> able to leave the session/logout cleanly.
>
> NB: >dev/null 2>&1 == &>/dev/null for bash-3* at least
>
> > And here's countdown.sh:
> >
> > #!/bin/sh
> >
> > REPO="$1"
> > REV="$2"
> >
> > for ((i=5; i>0; i-=1)); do
> > sleep 1
> > echo `date` REPO=${REPO} REV=${REV} PID=$$ I=$i >> /tmp/svnlog.txt
> > done
> >
> > And then in one window I monitor svnlog.txt:
> >
> > tail -f /tmp/svnlog.txt
> >
> > And in another, I change a file in a working copy and commit it:
> >
> > echo `date` > foo && svn ci -m ""
> >
> > It outputs this:
> >
> > Sending foo
> > Transmitting file data .
> >
> > And I get the countdown in the log file. And only after the countdown
> > finishes does the commit finish:
> >
> > Committed revision 7.
> >
> > This is Subversion 1.3.0 with APR 1.2.2 compiled through DarwinPorts on
> > Mac OS X 10.4.4 PPC. It's an FSFS repository created just now for
> > testing, accessed via the file:// protocol.
>
> My 2 yen above.
>
> Kalin.
>
> --
> |[ ~~~~~~~~~~~~~~~~~~~~~~ ]|
> +-> http://ThinRope.net/ <-+
> |[ ______________________ ]|
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>
Hi Kalin,
I don't think the </dev/null redirection is needed, but the more the
merrier I suppose :-) It should be OK in this instance for the shell to
inherit and not close the read end of some pipe or something as its stdin,
since Subversion doesn't write to a post-commit hook script's stdin.
I just tested this sleeping hook script case using Subversion 1.2.3 on
Debian 3.1 on an i386, with an empty local FSFS repo, and couldn't
duplicate the blocking problem that Artur's seeing. I cannot cause the
'svn ci' process to block waiting for the sleep to complete if the sleep
is backgrounded. Obviously, if the sleep is done in the foreground
(without '&') the parent process blocks; that's expected.
Using or not using redirection of stdin, stdout and stderr to/from
/dev/null makes no difference to the above results. Immediately after the
'svn ci' commit finishes (without blocking), I can run 'ps' and see the
sleep process still running in the background.
I can by contrast duplicate Artur's problem using SVN 1.3.0 on HPUX 11 on
HPPA, again with an empty local FSFS repo. On this box, I cannot *prevent*
the svn process from blocking until the sleep completes. Again,
redirecting all of stdin, stderr and stdout to/from /dev/null makes no
difference.
On the HPUX box, the child processes' inherited fds should all be being
closed due to the redirection of everything it is possible to redirect,
so unless Bash is leaking fds somehow, I don't think this is another
instance of the SSH hang-on-exit problem. And anyay it seems as if SVN
doesn't do any I/O to/from the child post-commit hook script process. But
only strace/truss/tusc/lsof/ltrace etc will tell me for sure is happening.
If tusc and friends tell me anything useful, I'll post it here.
Regards,
--matt
Matthew Sanderson
Senior Programmer (UNIX)
TCG Information Systems Pty Ltd
Sydney, Australia
matthew@formtrap.com
http://www.formtrap.com/
+61 (02) 8303 2407
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Feb 9 08:33:48 2006