arguments in rc for triggered programs...
...using 'renice' as example and first user (also had to re-arrange rc file to a more sensible order)
This commit is contained in:
parent
cb9794d55b
commit
2139099706
|
@ -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
|
* `GL_NO_DAEMON_NO_GITWEB` -- uncomment the appropriate lines in the rc
|
||||||
file, in both the `POST_COMPILE` and `POST_CREATE` trigger sections.
|
file, in both the `POST_COMPILE` and `POST_CREATE` trigger sections.
|
||||||
|
|
||||||
* `NICE_VALUE` -- use the `PRE_GIT` trigger to attach a program that renices
|
* `NICE_VALUE` -- uncomment the 'renice 10' line in the rc file. You can
|
||||||
the pid given by $GL_TID (that's the pid of the initial gitolite entry
|
also change the 10 to something else if you wish.
|
||||||
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.
|
|
||||||
|
|
||||||
* `GIT_PATH` -- gone, not needed. Just add these lines to the end of the rc
|
* `GIT_PATH` -- gone, not needed. Just add these lines to the end of the rc
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -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
|
won't work. (The `POST_COMPILE` trigger programs all just happen to not
|
||||||
require any arguments, so it works).
|
require any arguments, so it works).
|
||||||
|
|
||||||
## triggers and arguments
|
## common arguments
|
||||||
|
|
||||||
All triggers receive the name of the trigger as a string (example,
|
Triggers receive the following arguments:
|
||||||
`"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
|
1. any arguments mentioned in the rc file (for an example, see the renice
|
||||||
trigger, as above). In addition, they may receive other arguments pertaining
|
command in the PRE_GIT trigger sequence),
|
||||||
to the event that happened.
|
|
||||||
|
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
|
* `ACCESS_CHECK`: this fires once after each access check. The first is
|
||||||
just before invoking git-receive-pack or git-upload-pack. The second,
|
just before invoking git-receive-pack or git-upload-pack. The second,
|
||||||
|
|
|
@ -170,14 +170,12 @@ sub trigger {
|
||||||
} else {
|
} else {
|
||||||
for my $s ( @{ $rc{$rc_section} } ) {
|
for my $s ( @{ $rc{$rc_section} } ) {
|
||||||
|
|
||||||
# perl-ism; apart from keeping the full path separate from the
|
my ($pgm, @args) = split ' ', $s;
|
||||||
# simple name, this also protects %rc from change by implicit
|
$pgm = "$ENV{GL_BINDIR}/commands/$pgm";
|
||||||
# aliasing, which would happen if you touched $s itself
|
|
||||||
my $sfp = "$ENV{GL_BINDIR}/commands/$s";
|
|
||||||
|
|
||||||
_warn("skipped command '$s'"), next if not -x $sfp;
|
_warn("skipped command '$s'"), next if not -x $pgm;
|
||||||
trace( 2, "command: $s" );
|
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;
|
return;
|
||||||
|
@ -261,6 +259,17 @@ __DATA__
|
||||||
# uncomment (and change) this if you wish
|
# uncomment (and change) this if you wish
|
||||||
# DEFAULT_ROLE_PERMS => 'READERS @all',
|
# 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
|
# comment out or uncomment as needed
|
||||||
# these will run in sequence during the conf file parse
|
# these will run in sequence during the conf file parse
|
||||||
SYNTACTIC_SUGAR =>
|
SYNTACTIC_SUGAR =>
|
||||||
|
@ -268,6 +277,22 @@ __DATA__
|
||||||
# 'continuation-lines',
|
# '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
|
# comment out or uncomment as needed
|
||||||
# these will run in sequence after post-update
|
# these will run in sequence after post-update
|
||||||
POST_COMPILE =>
|
POST_COMPILE =>
|
||||||
|
@ -286,25 +311,6 @@ __DATA__
|
||||||
'post-compile/update-gitweb-access-list',
|
'post-compile/update-gitweb-access-list',
|
||||||
'post-compile/update-git-daemon-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',
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
5
src/commands/renice
Executable file
5
src/commands/renice
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
n=$1
|
||||||
|
[ "$n" = "PRE_GIT" ] && n=10
|
||||||
|
renice -n $n $GL_TID >/dev/null
|
Loading…
Reference in a new issue