added a cache flag to the settings client
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 23 Feb 2005 21:39:56 +0000 (21:39 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 23 Feb 2005 21:39:56 +0000 (21:39 +0000)
we now build a transport client in the unix server configure hook
in case anyone needs it..

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@97 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/UnixServer.pm
src/perlmods/OpenSRF/Utils/SettingsClient.pm

index 64e6292..e1a5d92 100644 (file)
@@ -152,20 +152,6 @@ sub serve {
        my $pid_file =  join("/", $client->config_value("dirs", "pid"),
                                $client->config_value("apps", $app, "unix_config", "unix_pid" ));
 
-
-
-=head
-       $self->{server}->{min_severs} = $min_servers;
-       $self->{server}->{max_severs} = $max_servers;
-       $self->{server}->{min_spare_severs} = $min_spare;
-       $self->{server}->{max_spare_servers} = $max_spare;
-       $self->{server}->{max_request} = $max_requests;
-       $self->{server}->{log_file} = $log_file;
-       $self->{server}->{pid_file} = $pid_file;
-       $self->{server}->{log_level} = 4;
-       $self->{server}->{proto} = "unix";
-=cut
-
        my $file = "/tmp/" . time . rand( $$ ) . "_$$";
        my $file_string = "min_servers $min_servers\nmax_servers $max_servers\n" .
                "min_spare_servers $min_spare\nmax_spare_servers $max_spare\n" .
@@ -184,6 +170,9 @@ sub configure_hook {
        my $self = shift;
        my $app = $self->app;
 
+       # boot a client
+       OpenSRF::System::bootstrap_client("system_client");
+
        $logger->debug( "Setting application implementaion for $app", DEBUG );
        my $client = OpenSRF::Utils::SettingsClient->new();
        my $imp = $client->config_value("apps", $app, "implementation");
@@ -197,6 +186,11 @@ sub configure_hook {
                $self->child_init_hook();
        }
 
+       my $con = OpenSRF::Transport::PeerHandle->retrieve;
+       if($con) {
+               $con->disconnect;
+       }
+
        return OpenSRF::Application->application_implementation;
 }
 
@@ -207,6 +201,8 @@ sub child_finish_hook {
 
 sub child_init_hook { 
 
+       $0 = "$0_child";
+
        my $self = shift;
 
        $logger->transport( 
index 86b25f0..6dbf96e 100755 (executable)
@@ -13,6 +13,14 @@ sub new {return bless({},shift());}
 my $session;
 $host_config = undef;
 
+my $we_cache = 1;
+sub set_cache {
+       my($self, $val) = @_;
+       if($val) { $we_cache = 1; }
+}
+
+
+
 # ------------------------------------
 # utility method for grabbing config info
 sub config_value {
@@ -21,7 +29,13 @@ sub config_value {
 
        my $bsconfig = OpenSRF::Utils::Config->current;
        my $host = $bsconfig->env->hostname;
-       if(!$host_config) { grab_host_config($host); }
+
+       if($we_cache) {
+               if(!$host_config) { grab_host_config($host); }
+       } else {
+               grab_host_config($host);
+       }
+
        if(!$host_config) {
                throw OpenSRF::EX::Config ("Unable to retrieve host config for $host" );
        }