chiark / gitweb /
use speedy_cgi
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 28 Jun 2010 01:42:36 +0000 (02:42 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 28 Jun 2010 01:42:36 +0000 (02:42 +0100)
cgi

diff --git a/cgi b/cgi
index c348508dd9b4001ff849897f5b7df2ffb87a36b1..9fc7b5ce979dc419754edb063fe71496a5d384a2 100755 (executable)
--- a/cgi
+++ b/cgi
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/speedy -w -- -t100 -M1
 
 use strict qw(vars);
+use CGI::SpeedyCGI qw/:standard -no_xhtml/;
 use CGI qw/:standard -no_xhtml/;
 
 sub fail ($) {
@@ -12,12 +13,14 @@ sub fail ($) {
     exit 0;
 }
 
-our $R= '/var/lib/collectd/rrd/chiark.greenend.org.uk';
-our $SELF= '/home/ijackson/things/rrd-graphs';
+our (@sections, %section_groups, %group_elems, %graphs);
 
-my $self= url(-relative=>1);
+#---------- initialisation code, run once - graphs setup ----------
 
-our (@sections, %section_groups, %group_elems, %graphs);
+BEGIN {
+
+our $R= '/var/lib/collectd/rrd/chiark.greenend.org.uk';
+our $SELF= '/home/ijackson/things/rrd-graphs';
 
 our @timeranges= (3600, map { $_*86400 } qw(1 7 28), 13*7+1, 366);
 
@@ -203,6 +206,12 @@ foreach my $src (sort { news_name_sortkey($a) cmp news_name_sortkey($b) }
           ]);
 }
 
+}
+
+#---------- right, that was the initialisation ----------
+
+our $self= url(-relative=>1);
+
 if (param('debug')) {
     print "Content-Type: text/plain\n\n";
 }
@@ -240,9 +249,9 @@ sub num_param ($$$$) {
     return $v + 0;
 }
 
-my $group= param('graph');
+our $group= param('graph');
 
-my $elem= param('elem');
+our $elem= param('elem');
 if (defined $elem) {
     my $g= $graphs{$section,$group,$elem};
     die unless $g;
@@ -319,7 +328,7 @@ sub start_page ($) {
     print h1("$title");
 }
 
-my $detail= param('detail');
+our $detail= param('detail');
 if ($detail) {
     my $elems= $group_elems{$section,$detail};
     die unless $elems;