Changeset 490


Ignore:
Timestamp:
04/09/13 15:18:00 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak RPC to run as FastCGI, and add another config option to control
the number of requests to handle before respawning

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r489 r490  
    166166                log_failures    => 1,   # log all evarthing by default
    167167                perpage         => 15,
     168                maxfcgi         => 100, # reasonable default?
    168169        );
    169170
     
    13381339      # RPC options
    13391340      $config{rpcmode}          = $1 if /^rpc_mode\s*=\s*(socket|HTTP|XMLRPC)\s*$/i;
     1341      $config{maxfcgi}          = $1 if /^max_fcgi_requests\s*=\s*(\d+)\s*$/i;
    13401342      if (my ($tmp) = /^rpc_iplist\s*=\s*(.+)/i) {
    13411343        my @ips = split /[,\s]+/, $tmp;
  • trunk/dns-rpc.cgi

    r486 r490  
    2424# don't remove!  required for GNU/FHS-ish install from tarball
    2525use lib '.';    ##uselib##
    26 
    27 use DNSDB;      # note we're not importing subs;  this lets us (ab)use the same sub names here for convenience
    28 use Data::Dumper;
    29 
     26use DNSDB;
     27
     28use FCGI;
    3029#use Frontier::RPC2;
    3130use Frontier::Responder;
     
    6968};
    7069
    71 my $res = Frontier::Responder->new(
     70my $reqcnt = 0;
     71
     72while (FCGI::accept >= 0) {
     73  my $res = Frontier::Responder->new(
    7274        methods => $methods
    7375        );
    7476
    75 # "Can't do that" errors
    76 if (!$dnsdb) {
    77   print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $msg);
    78   exit;
    79 }
    80 ##fixme:  fail on missing rpcuser/rpcsystem args
    81 
    82 print $res->answer;
     77  # "Can't do that" errors
     78  if (!$dnsdb) {
     79    print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $dnsdb->err);
     80  } else {
     81    print $res->answer;
     82  }
     83  last if $reqcnt++ > $dnsdb->{maxfcgi};
     84} # while FCGI::accept
     85
    8386
    8487exit;
     
    8891##
    8992
    90 # Utility subs
     93# Check RPC ACL
    9194sub _aclcheck {
    9295  my $subsys = shift;
Note: See TracChangeset for help on using the changeset viewer.