Changeset a1fc8c16f19a8e8128cecd27530bfa646e855fae

Show
Ignore:
Timestamp:
03/20/10 02:37:50 (5 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1269052670 +0000
git-parent:

[b4a01ee848c6689e508db6c683e95fd59cb17f28]

git-author:
Mark Harrison <mark@omniti.com> 1269052670 +0000
Message:

Remove module reloading code.

It never quite worked, and module loading had changed significantly. A fixed
version may be included in the future.

git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@269 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Status.pm

    rb4a01ee ra1fc8c1  
    484484    } 
    485485} 
    486 sub purge { 
    487     # This removes status information for modules that are no longer loaded 
    488  
    489     # Generate list of current modules 
    490     my %loaded = (); 
    491     my ($self, $config) = @_; 
    492     while (my ($type, $mods) = each(%{$config->{Module}}) ) { 
    493         $loaded{$type} = (); 
    494         foreach (@$mods) { 
    495             $loaded{$type}{$_->{'check_name'}} = 1; 
    496         } 
    497     } 
    498  
    499     # Debugging 
    500     #while (my ($key, $value) = each(%loaded) ) { 
    501     #    print STDERR "$key: "; 
    502     #    while (my ($mod, $dummy) = each (%$value) ) { 
    503     #        print STDERR "$mod "; 
    504     #    } 
    505     #    print "\n"; 
    506     #} 
    507  
    508     # Compare $self->{store} with list of loaded modules 
    509     while (my ($type, $value) = each (%{$self->{store}})) { 
    510         while (my ($name, $value2) = each (%$value)) { 
    511             if (!exists($loaded{$type}) || !exists($loaded{$type}{$name})) { 
    512                 #print STDERR "$type $name\n"; 
    513                 delete $self->{store}->{$type}->{$name}; 
    514                 if (scalar(keys %{$self->{store}->{$type}}) == 0) { 
    515                     #print STDERR "$type has no more objects, deleting\n"; 
    516                     delete $self->{store}->{$type}; 
    517                 } 
    518             } 
    519         } 
    520     } 
    521 } 
    522486sub close { 
    523487    my $self = shift; 
  • resmon

    rb4a01ee ra1fc8c1  
    4343    $config->{interface} = $interface if($interface); 
    4444} 
    45  
    46 sub reconfigure { 
    47     my $modstatus = ""; 
    48     print STDERR "Reloading modules...\n"; 
    49     my $modules = $config->{Module}; 
    50     while ( my ($key, $value) = each(%$modules) ) { 
    51         my $mod = $value->[0]; # Only need the first of each module 
    52         # Called this way rather than $mod->reload_module() in order to deal 
    53         # with modules that failed to load on startup and won't have a 
    54         # reload_module method. 
    55         my $errs = Resmon::Module::reload_module($mod); 
    56         if ($errs) { 
    57             my $modname = ref($mod) || $mod; 
    58             $modname =~ s/Resmon::Module:://; 
    59             $modstatus .= "$modname "; 
    60             print STDERR " Failed to reload module $modname\n"; 
    61             print STDERR $errs; 
    62             print STDERR " This module is no longer available.\n"; 
    63         } 
    64     } 
    65     print STDERR "Reloading configuration...\n"; 
    66     eval { configure(); }; 
    67     if ($@) { 
    68         # The config object is recreated every time we reload, so we shouldn't 
    69         # need to reset this BAD value to empty on a successful load. 
    70         $config->{'configstatus'} = "BAD"; 
    71         print STDERR " Failed to reload: "; 
    72         print STDERR $@; 
    73         print STDERR " Continuing with old configuration\n"; 
    74     } 
    75  
    76     $config->{'modstatus'} = $modstatus; 
    77     $status->purge($config); 
    78 } 
    79  
    80 my $sighup = 0; 
    81 sub sighup_handler { $sighup = 1; } 
    82 $SIG{'HUP'} = \&sighup_handler; 
    8345 
    8446configure(); 
     
    162124    $status->close(); 
    163125    die "Exiting.\n" if($sigint); 
    164     if ($sighup) { 
    165         $sighup = 0; 
    166         reconfigure(); 
    167     } else { 
    168         reap_zombies(); 
    169         wait_interval(); 
    170         reap_zombies(); 
    171     } 
     126    reap_zombies(); 
     127    wait_interval(); 
     128    reap_zombies(); 
    172129    die "Exiting.\n" if($sigint); 
    173130    print "\n---- ".localtime(time)."----------\n"