From: erickson Date: Wed, 23 Feb 2005 21:39:56 +0000 (+0000) Subject: added a cache flag to the settings client X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5900b9e407d1e4268cffaf6fd786023c3472d922;p=working%2FOpenSRF.git added a cache flag to the settings client 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 --- diff --git a/src/perlmods/OpenSRF/UnixServer.pm b/src/perlmods/OpenSRF/UnixServer.pm index 64e6292..e1a5d92 100644 --- a/src/perlmods/OpenSRF/UnixServer.pm +++ b/src/perlmods/OpenSRF/UnixServer.pm @@ -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( diff --git a/src/perlmods/OpenSRF/Utils/SettingsClient.pm b/src/perlmods/OpenSRF/Utils/SettingsClient.pm index 86b25f0..6dbf96e 100755 --- a/src/perlmods/OpenSRF/Utils/SettingsClient.pm +++ b/src/perlmods/OpenSRF/Utils/SettingsClient.pm @@ -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" ); }