From 969f1870b4bd380e3a1d644fff9daddea962cca0 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 7 Mar 2007 21:22:20 +0000 Subject: [PATCH] refactored the unix::server config handling by getting rid of the old temp config files and passing config params directly to the net::server run() method git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@840 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/UnixServer.pm | 60 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/perlmods/OpenSRF/UnixServer.pm b/src/perlmods/OpenSRF/UnixServer.pm index f20b960..120f73c 100644 --- a/src/perlmods/OpenSRF/UnixServer.pm +++ b/src/perlmods/OpenSRF/UnixServer.pm @@ -68,7 +68,6 @@ sub process_request { my $data; my $d; while( $d = ) { $data .= $d; } - my $orig = $0; $0 = "$0*"; @@ -162,38 +161,41 @@ sub serve { $0 = "OpenSRF master [$app]"; - system("rm -f /tmp/opensrf_unix_$app*"); - my $client = OpenSRF::Utils::SettingsClient->new(); - $logger->transport("Max Req: " . $client->config_value("apps", $app, "unix_config", "max_requests" ), INFO ); - - my $min_servers = $client->config_value("apps", $app, "unix_config", "min_children" ); - my $max_servers = $client->config_value("apps", $app, "unix_config", "max_children" ); - my $min_spare = $client->config_value("apps", $app, "unix_config", "min_spare_children" ); - my $max_spare = $client->config_value("apps", $app, "unix_config", "max_spare_children" ); - my $max_requests = $client->config_value("apps", $app, "unix_config", "max_requests" ); - my $log_file = join("/", $client->config_value("dirs", "log"), - $client->config_value("apps", $app, "unix_config", "unix_log" )); - my $port = join("/", $client->config_value("dirs", "sock"), - $client->config_value("apps", $app, "unix_config", "unix_sock" )); - my $pid_file = join("/", $client->config_value("dirs", "pid"), - $client->config_value("apps", $app, "unix_config", "unix_pid" )); - - my $file = "/tmp/" . "opensrf_unix_$app"."_" . 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" . - "max_requests $max_requests\nlog_file $log_file\nproto unix\n" . - "port $port\npid_file $pid_file\nlog_level 3\n"; - - open F, "> $file" or die "Can't open $file : $!"; - print F $file_string; - close F; - - $self->run( 'conf_file' => $file ); - unlink($file); + my @base = ('apps', $app, 'unix_config' ); + + my $min_servers = $client->config_value(@base, 'min_children'); + my $max_servers = $client->config_value(@base, "max_children" ); + my $min_spare = $client->config_value(@base, "min_spare_children" ); + my $max_spare = $client->config_value(@base, "max_spare_children" ); + my $max_requests = $client->config_value(@base, "max_requests" ); + # fwiw, these file paths are (obviously) not portable + my $log_file = join("/", $client->config_value("dirs", "log"), $client->config_value(@base, "unix_log" )); + my $port = join("/", $client->config_value("dirs", "sock"), $client->config_value(@base, "unix_sock" )); + my $pid_file = join("/", $client->config_value("dirs", "pid"), $client->config_value(@base, "unix_pid" )); + + $min_spare ||= $min_servers; + $max_spare ||= $max_servers; + $max_requests ||= 1000; + + $logger->info("UnixServer: min=$min_servers, max=$max_servers, min_spare=$min_spare ". + "max_spare=$max_spare, max_req=$max_requests, log_file=$log_file, port=$port, pid_file=$pid_file"); + + $self->run( + min_servers => $min_servers, + max_servers => $max_servers, + min_spare_servers => $min_spare, + max_spare_servers => $max_spare, + max_requests => $max_requests, + log_file => $log_file, + port => $port, + proto => 'unix', + pid_file => $pid_file, + ); } + sub configure_hook { my $self = shift; my $app = $self->app; -- 2.11.0