From: erickson Date: Wed, 23 Feb 2005 22:17:58 +0000 (+0000) Subject: added some logging. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e2e5f7529afb804554abfacbf667783ae8a23c8d;p=working%2FOpenSRF.git added some logging. we now do an introspection lookup explicitly in math bench on child init we build and tear down a connection in the unix:server configure hook so that an applications 'initialize' method can do remote requests inbound now only opens the socket after receiving data so that a restart of a unix server won't require a restart of its companion listener process git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@98 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/OpenSRF/Application/Demo/Math.pm b/src/perlmods/OpenSRF/Application/Demo/Math.pm index e373dc5..fe030a8 100644 --- a/src/perlmods/OpenSRF/Application/Demo/Math.pm +++ b/src/perlmods/OpenSRF/Application/Demo/Math.pm @@ -8,6 +8,11 @@ use OpenSRF::EX qw/:try/; use strict; use warnings; + +sub child_init { + OpenSRF::Application->method_lookup("opensrf.nunya"); +} + sub DESTROY{} our $log = 'OpenSRF::Utils::Logger'; diff --git a/src/perlmods/OpenSRF/System.pm b/src/perlmods/OpenSRF/System.pm index 6d2c253..bcf474d 100644 --- a/src/perlmods/OpenSRF/System.pm +++ b/src/perlmods/OpenSRF/System.pm @@ -55,7 +55,7 @@ $SIG{INT} = sub { instance()->killall(); }; $SIG{HUP} = sub{ instance()->hupall(); }; -#$SIG{CHLD} = \&process_automation; +$SIG{CHLD} = \&process_automation; { @@ -270,7 +270,7 @@ sub process_automation { if( $newpid ) { $self->pid_hash( $newpid, $method ); } - else { $0 = $method; eval $method; exit; } + else { eval $method; exit; } } } @@ -291,7 +291,6 @@ sub launch_settings { } else { my $apname = "settings"; - $apname =~ tr/[a-z]/[A-Z]/; $0 = "OpenSRF App ($apname)"; eval _unixserver( "settings" ); if($@) { die "$@\n"; } @@ -313,8 +312,7 @@ sub launch_settings_listener { } else { my $apname = $app; - $apname =~ tr/[a-z]/[A-Z]/; - $0 = "Listener ($apname)"; + $0 = "OpenSRF listener ($apname)"; eval _listener( $app ); exit; } @@ -339,7 +337,6 @@ sub launch_unix { } else { my $apname = $app; - $apname =~ tr/[a-z]/[A-Z]/; $0 = "OpenSRF App ($apname)"; eval _unixserver( $app ); exit; @@ -366,9 +363,7 @@ sub launch_listener { } else { my $apname = $app; - $apname =~ tr/[a-z]/[A-Z]/; $0 = "Listener ($apname)"; - warn "Launching Listener with command:\n " . _listener($app) . "\n"; eval _listener( $app ); exit; } diff --git a/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm b/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm index 8d1988e..706699a 100644 --- a/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm +++ b/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm @@ -523,7 +523,8 @@ sub process { unless( $self->{_socket}->connected ) { OpenSRF::EX::JabberDisconnected->throw( - "This JabberClient instance is no longer connected to the server", ERROR ); + "This JabberClient instance is no longer connected to the server " . + $self->username . " : " . $self->resource, ERROR ); } my $val = $self->timed_read( $timeout ); diff --git a/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm b/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm index 6d7616d..72d559c 100644 --- a/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm +++ b/src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm @@ -112,19 +112,18 @@ sub listen { $logger->transport( $self->{app} . " going into listen loop", INFO ); while(1) { - my $sock = $self->unix_sock(); - my $socket = IO::Socket::UNIX->new( Peer => $sock ); - throw OpenSRF::EX::Socket( "Unable to connect to UnixServer: socket-file: $sock \n :=> $! " ) - unless ($socket->connected); - + my $sock = $self->unix_sock(); my $o = $self->process( -1 ); if( ! defined( $o ) ) { throw OpenSRF::EX::Jabber( "Listen Loop failed at 'process()'" ); } - print $socket $o; + my $socket = IO::Socket::UNIX->new( Peer => $sock ); + throw OpenSRF::EX::Socket( "Unable to connect to UnixServer: socket-file: $sock \n :=> $! " ) + unless ($socket->connected); + print $socket $o; $socket->close; } diff --git a/src/perlmods/OpenSRF/UnixServer.pm b/src/perlmods/OpenSRF/UnixServer.pm index e1a5d92..0ef56e0 100644 --- a/src/perlmods/OpenSRF/UnixServer.pm +++ b/src/perlmods/OpenSRF/UnixServer.pm @@ -137,6 +137,8 @@ sub serve { my $app = $self->app(); + $0 = "OpenSRF master ($app)"; + my $client = OpenSRF::Utils::SettingsClient->new(); $logger->transport("Max Req: " . $client->config_value("apps", $app, "unix_config", "max_requests" ), INFO ); @@ -201,12 +203,12 @@ sub child_finish_hook { sub child_init_hook { - $0 = "$0_child"; + $0 =~ s/master/drone/g; my $self = shift; - $logger->transport( - "Creating PeerHandle from UnixServer child_init_hook", INTERNAL ); +# $logger->transport( +# "Creating PeerHandle from UnixServer child_init_hook", INTERNAL ); OpenSRF::Transport::PeerHandle->construct( $self->app() ); $logger->transport( "PeerHandle Created from UnixServer child_init_hook", INTERNAL );