ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/checkrusage.ext
Revision: 1.4
Committed: Sat Jan 27 00:14:03 2007 UTC (17 years, 4 months ago) by root
Branch: MAIN
CVS Tags: rel-2_2, rel-2_3, rel-2_0, rel-2_1
Changes since 1.3: +0 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3     # restart server when certain resource limits are exceeded
4    
5     our $MAX_VMSIZE = $cf::CFG{checkrusage}{vmsize} || 1_000_000_000;
6    
7     $^O eq "linux" or die "only linux supported right now.\n";
8    
9     Event->timer (
10     reentrant => 0,
11     data => cf::WF_AUTOCANCEL,
12 root 1.2 interval => 10,
13     after => 10,
14 root 1.1 cb => sub {
15     open my $fh, "</proc/self/stat"
16     or return;
17    
18     sysread $fh, my $stat, 4096; # only a single line
19     my $vmsize = (split / /, $stat)[22];
20    
21 root 1.3 cf::cleanup "memory usage growing high, server would run out of memory soon", 0
22     if $vmsize >= $MAX_VMSIZE;
23 root 1.1 },
24     );