[OpenSRF-GIT] OpenSRF branch master updated. df3155f9a3d9259ce64b27fb834450f99e85d8e2
Evergreen Git
git at git.evergreen-ils.org
Sat Mar 16 21:44:58 EDT 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".
The branch, master has been updated
via df3155f9a3d9259ce64b27fb834450f99e85d8e2 (commit)
via dd09c46cfd3bc445a879257bb530117b904f09fa (commit)
from 51dfd2c93ded26db5820201a1e43ed8e3cdb7d99 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit df3155f9a3d9259ce64b27fb834450f99e85d8e2
Author: Bill Erickson <berick at esilibrary.com>
Date: Tue Oct 16 09:28:20 2012 -0400
Minor whitespace repairs in Server.pm
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/perl/lib/OpenSRF/Server.pm b/src/perl/lib/OpenSRF/Server.pm
index 35d135a..d8103b6 100644
--- a/src/perl/lib/OpenSRF/Server.pm
+++ b/src/perl/lib/OpenSRF/Server.pm
@@ -98,7 +98,7 @@ sub handle_sighup {
# reload the opensrf config
# note: calling ::Config->load() results in ever-growing
# package names, which eventually causes an exception
- OpenSRF::Utils::Config->current->_load(
+ OpenSRF::Utils::Config->current->_load(
force => 1,
config_file => OpenSRF::Utils::Config->current->FILE
);
@@ -124,7 +124,7 @@ sub handle_sighup {
sub run {
my $self = shift;
- $logger->set_service($self->{service});
+ $logger->set_service($self->{service});
$SIG{$_} = sub { $self->cleanup; } for (qw/INT TERM QUIT/);
$SIG{CHLD} = sub { $self->reap_children(); };
@@ -525,7 +525,7 @@ sub unregister_routers {
my $self = shift;
return unless $self->{osrf_handle}->tcp_connected;
- for my $router (@{$self->{routers}}) {
+ for my $router (@{$self->{routers}}) {
$logger->info("server: disconnecting from router $router");
$self->{osrf_handle}->send(
to => $router,
@@ -583,8 +583,8 @@ sub init {
my $service = $self->{parent}->{service};
$0 = "OpenSRF Drone [$service]";
OpenSRF::Transport::PeerHandle->construct($service);
- OpenSRF::Application->application_implementation->child_init
- if (OpenSRF::Application->application_implementation->can('child_init'));
+ OpenSRF::Application->application_implementation->child_init
+ if (OpenSRF::Application->application_implementation->can('child_init'));
}
# ----------------------------------------------------------------
@@ -629,8 +629,8 @@ sub run {
$chatty and $logger->internal("server: child process shutting down after reaching max_requests");
- OpenSRF::Application->application_implementation->child_exit
- if (OpenSRF::Application->application_implementation->can('child_exit'));
+ OpenSRF::Application->application_implementation->child_exit
+ if (OpenSRF::Application->application_implementation->can('child_exit'));
}
# ----------------------------------------------------------------
commit dd09c46cfd3bc445a879257bb530117b904f09fa
Author: Bill Erickson <berick at esilibrary.com>
Date: Mon Oct 15 17:23:19 2012 -0400
Perl SIGHUP handling and config reloading
Sending the HUP signal to a Perl Listener process now results in the
following:
* Reload the opensrf_core config
* re-init the logger
* kill idle child processes
* child processes that are active when the signal is received are
tracked and killed once they become idle.
* New children are spawned per the min child settings
The primary use case for these changes is temporarily changing the log
level (or log file) for a given service for debug purposes. It may also
be used, for example, to gracefully recover excess RAM consumed by a
child process.
Not all values in opensrf_core.xml are affected by a SIGHUP. Since the
goal is a gracful reload, no attempt is made by the listener process to
re-connect to jabber or re-register with the opensrf router(s). Child
processes will by necessity connect to Jabber during startup, though, so
any changes to the jabber configuration will affect child processes. In
general, it's best to affect jabber configuration changes with a true
service restart.
opensrf.xml (opensrf.settings config) is not reloaded, so min/max child
settings will not be affected.
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/perl/lib/OpenSRF/Server.pm b/src/perl/lib/OpenSRF/Server.pm
index 8034a1a..35d135a 100644
--- a/src/perl/lib/OpenSRF/Server.pm
+++ b/src/perl/lib/OpenSRF/Server.pm
@@ -43,6 +43,7 @@ sub new {
$self->{routers} = []; # list of registered routers
$self->{active_list} = []; # list of active children
$self->{idle_list} = []; # list of idle children
+ $self->{sighup_pending} = [];
$self->{pid_map} = {}; # map of child pid to child for cleaner access
$self->{sig_pipe} = 0; # true if last syswrite failed
@@ -87,6 +88,35 @@ sub cleanup {
}
# ----------------------------------------------------------------
+# SIGHUP handler. Kill all idle children. Copy list of active
+# children into sighup_pending list for later cleanup.
+# ----------------------------------------------------------------
+sub handle_sighup {
+ my $self = shift;
+ $logger->info("server: caught SIGHUP; reloading children");
+
+ # reload the opensrf config
+ # note: calling ::Config->load() results in ever-growing
+ # package names, which eventually causes an exception
+ OpenSRF::Utils::Config->current->_load(
+ force => 1,
+ config_file => OpenSRF::Utils::Config->current->FILE
+ );
+
+ # force-reload the logger config
+ OpenSRF::Utils::Logger::set_config(1);
+
+ # copy active list into pending list for later cleanup
+ $self->{sighup_pending} = [ @{$self->{active_list}} ];
+
+ # idle_list will be modified as children are reaped.
+ my @idle = @{$self->{idle_list}};
+
+ # idle children are the reaper's plaything
+ $self->kill_child($_) for @idle;
+}
+
+# ----------------------------------------------------------------
# Waits on the jabber socket for inbound data from the router.
# Each new message is passed off to a child process for handling.
# At regular intervals, wake up for min/max spare child maintenance
@@ -98,6 +128,7 @@ sub run {
$SIG{$_} = sub { $self->cleanup; } for (qw/INT TERM QUIT/);
$SIG{CHLD} = sub { $self->reap_children(); };
+ $SIG{HUP} = sub { $self->handle_sighup(); };
$self->spawn_children;
$self->build_osrf_handle;
@@ -313,6 +344,27 @@ sub check_status {
$chatty and $logger->internal(sprintf(
"server: %d idle and %d active children after status update",
scalar(@{$self->{idle_list}}), scalar(@{$self->{active_list}})));
+
+ # some children just went from active to idle. let's see
+ # if any of them need to be killed from a previous sighup.
+
+ for my $child (@{$self->{sighup_pending}}) {
+ if (grep {$_ == $child->{pid}} @pids) {
+
+ $chatty and $logger->internal(
+ "server: killing previously-active ".
+ "child after receiving SIGHUP: $child");
+
+ # remove the pending child
+ $self->{sighup_pending} = [
+ grep {$_->{pid} != $child->{pid}}
+ @{$self->{sighup_pending}}
+ ];
+
+ # kill the pending child
+ $self->kill_child($child)
+ }
+ }
}
# ----------------------------------------------------------------
@@ -348,7 +400,6 @@ sub reap_children {
$chatty and $logger->internal(sprintf(
"server: %d idle and %d active children after reap_children",
scalar(@{$self->{idle_list}}), scalar(@{$self->{active_list}})));
-
}
# ----------------------------------------------------------------
diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm
index f51f16e..f97d557 100644
--- a/src/perl/lib/OpenSRF/Utils/Logger.pm
+++ b/src/perl/lib/OpenSRF/Utils/Logger.pm
@@ -57,8 +57,9 @@ my $isclient; # true if we control the osrf_xid
# load up our config options
sub set_config {
+ my $force = shift;
- return if defined $config;
+ return if defined $config and !$force;
$config = OpenSRF::Utils::Config->current;
if( !defined($config) ) {
-----------------------------------------------------------------------
Summary of changes:
src/perl/lib/OpenSRF/Server.pm | 65 ++++++++++++++++++++++++++++++----
src/perl/lib/OpenSRF/Utils/Logger.pm | 3 +-
2 files changed, 60 insertions(+), 8 deletions(-)
hooks/post-receive
--
OpenSRF
More information about the opensrf-commits
mailing list