diff --git a/doc/g2rcdiff.mkd b/doc/g2rcdiff.mkd index 81af122..53ebd55 100644 --- a/doc/g2rcdiff.mkd +++ b/doc/g2rcdiff.mkd @@ -64,12 +64,8 @@ or mechanisms, but you have to do some setup work. * `GL_NO_DAEMON_NO_GITWEB` -- uncomment the appropriate lines in the rc file, in both the `POST_COMPILE` and `POST_CREATE` trigger sections. - * `NICE_VALUE` -- use the `PRE_GIT` trigger to attach a program that renices - the pid given by $GL_TID (that's the pid of the initial gitolite entry - point, usually gitolite-shell, and propagates from there once set). - - You may have to add this list to the rc file; if you don't know perl use - one of the others as a model or ask me. + * `NICE_VALUE` -- uncomment the 'renice 10' line in the rc file. You can + also change the 10 to something else if you wish. * `GIT_PATH` -- gone, not needed. Just add these lines to the end of the rc file: diff --git a/doc/triggers.mkd b/doc/triggers.mkd index 50e74bd..637a04b 100644 --- a/doc/triggers.mkd +++ b/doc/triggers.mkd @@ -42,13 +42,23 @@ However if the triggered code depends on arguments (see next section) this won't work. (The `POST_COMPILE` trigger programs all just happen to not require any arguments, so it works). -## triggers and arguments +## common arguments -All triggers receive the name of the trigger as a string (example, -`"POST_COMPILE"`) as the first argument, so they can know who invoked them. -(This allows you to write the same program and fire it from more than one -trigger, as above). In addition, they may receive other arguments pertaining -to the event that happened. +Triggers receive the following arguments: + +1. any arguments mentioned in the rc file (for an example, see the renice + command in the PRE_GIT trigger sequence), + +2. the name of the trigger as a string (example, `"POST_COMPILE"`), so you + can call the same program from multiple triggers and know where it was + called from, + +3. followed by zero or more arguments specific to the trigger, as given in + the next section. + +## trigger-specific details + +Here's all you need to know about each specific trigger. * `ACCESS_CHECK`: this fires once after each access check. The first is just before invoking git-receive-pack or git-upload-pack. The second, diff --git a/src/Gitolite/Rc.pm b/src/Gitolite/Rc.pm index c4c3bcd..bdd6755 100644 --- a/src/Gitolite/Rc.pm +++ b/src/Gitolite/Rc.pm @@ -170,14 +170,12 @@ sub trigger { } else { for my $s ( @{ $rc{$rc_section} } ) { - # perl-ism; apart from keeping the full path separate from the - # simple name, this also protects %rc from change by implicit - # aliasing, which would happen if you touched $s itself - my $sfp = "$ENV{GL_BINDIR}/commands/$s"; + my ($pgm, @args) = split ' ', $s; + $pgm = "$ENV{GL_BINDIR}/commands/$pgm"; - _warn("skipped command '$s'"), next if not -x $sfp; + _warn("skipped command '$s'"), next if not -x $pgm; trace( 2, "command: $s" ); - _system( $sfp, $rc_section, @_ ); # they better all return with 0 exit codes! + _system( $pgm, @args, $rc_section, @_ ); # they better all return with 0 exit codes! } } return; @@ -261,6 +259,17 @@ __DATA__ # uncomment (and change) this if you wish # DEFAULT_ROLE_PERMS => 'READERS @all', + # comment out or uncomment as needed + # these are available to remote users + COMMANDS => + { + 'help' => 1, + 'info' => 1, + 'desc' => 1, + 'perms' => 1, + 'writes' => 1, + }, + # comment out or uncomment as needed # these will run in sequence during the conf file parse SYNTACTIC_SUGAR => @@ -268,6 +277,22 @@ __DATA__ # 'continuation-lines', ], + # comment out or uncomment as needed + # these will run in sequence at the start, before a git operation has started + PRE_GIT => + [ + # if you use this, make this the first item in the list + # 'renice 10', + ], + + # comment out or uncomment as needed + # these will run in sequence at the end, after a git operation has ended + POST_GIT => + [ + # if you use this, make this the last item in the list + # 'cpu-time', + ], + # comment out or uncomment as needed # these will run in sequence after post-update POST_COMPILE => @@ -286,25 +311,6 @@ __DATA__ 'post-compile/update-gitweb-access-list', 'post-compile/update-git-daemon-access-list', ], - - # comment out or uncomment as needed - # these are available to remote users - COMMANDS => - { - 'help' => 1, - 'info' => 1, - 'desc' => 1, - 'perms' => 1, - 'writes' => 1, - }, - - # comment out or uncomment as needed - # these will run in sequence at the end, after a git operation has ended - POST_GIT => - [ - # if you use this, make this the last item in the list - # 'cpu-time', - ], ); # ------------------------------------------------------------------------------ diff --git a/src/commands/renice b/src/commands/renice new file mode 100755 index 0000000..ba0b726 --- /dev/null +++ b/src/commands/renice @@ -0,0 +1,5 @@ +#!/bin/sh + +n=$1 +[ "$n" = "PRE_GIT" ] && n=10 +renice -n $n $GL_TID >/dev/null