09-02-2008, 10:57 AM
If your server isn't on a dedicated box running NOTHING else you may experiance latancy when apache pegs the CPU at 100% for days on end (you know, because new supporters are downloading your (truthful) propaganda... or maybe playing your web-terminal enabled little videogames... or apache has some bug... who knows) and this will kill any performance in the game.
The soultion is RENICE (on linux boxes). But you restart your server sometimes, so the soultion becomes renice in a script placed in /etc/cron.hourly/
The soultion is RENICE (on linux boxes). But you restart your server sometimes, so the soultion becomes renice in a script placed in /etc/cron.hourly/
Code:
#!/usr/bin/perl
#autorenice_of_x by MikeeUSA ((C) GNU GPL v2)
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
##$ENV{'PATH'} = '/bin/';
$username = "nexuizuser"; #User that program belongs to
$niceness = "-14"; #Nice value (less == higher priority)
$program = 'nexuiz-linux-686-dedicated'; #Program to renice
$rnpid = '';
$user = '';
##print"$program\n";
dict0();
$pid = `/bin/pidof $program`;
##print"$pid\n";
chomp($pid);
dict1();
sub dict0 {
$program =~ s/\W\-\_//g;
}
sub dict1 {
##print"$pid\n";
(@buffe) = split(/ /,$pid);
##print"@buffe\n";
foreach (@buffe) {
$_ =~ s/\W//g;
$rnpid = $_;
$user = `ps -p $_ -o user`;
$user =~ s/USER//g;
$user =~ s/\n//g;
##print"$user\n";
$user =~ s/\W//g;
##print"$user\n";
if ($user eq $username) {
print"renice $niceness -p $rnpid";
system("renice $niceness -p $rnpid");
print "Reniced $rnpid ($program) to $niceness\n";
}
}
}