make --diagnostic also report min/max configured drones
authorGalen Charlton <gmc@esilibrary.com>
Fri, 6 Feb 2015 15:49:05 +0000 (15:49 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 6 Feb 2015 15:49:28 +0000 (15:49 +0000)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
bin/opensrf-perl.pl.in

index 82123af..36d0f13 100755 (executable)
@@ -228,7 +228,7 @@ sub do_diagnostic {
 
     my @conf_services;
     if ($alive) {
-        @conf_services = map {$_->{service}} (@perl_services, @nonperl_services);
+        @conf_services = (@perl_services, @nonperl_services);
     }
     
     my @services;
@@ -237,7 +237,7 @@ sub do_diagnostic {
     } else {
         @services = get_service_list_from_files(1);
         if ($alive) {
-            push(@services, @conf_services);
+            push(@services, map {$_->{service}} @conf_services);
         }
     }
     
@@ -273,12 +273,16 @@ sub do_diagnostic {
             } else {
                 my @drones = `pgrep -f "Drone \\[$svc\\]"`;
                 $str .= "#drones=".scalar(@drones);
+                if (my ($service_info) = grep {$_->{service} eq $svc} @conf_services) {
+                    $str .= '/' . $service_info->{min_drones};
+                    $str .= '/' . $service_info->{max_drones};
+                }
                 msg($str);
                 msg("\tERR $svc has no running drones.") unless @drones;
             }
 
             msg("\tERR $svc [$pid] NOT configured for this host.")
-                unless grep {$_ eq $svc} @conf_services 
+                unless grep {$_->{service} eq $svc} @conf_services 
                 or $svc eq 'router';
 
             msg("\tERR $svc [$pid] NOT found in PID file.")
@@ -340,12 +344,18 @@ sub do_init {
                 next;
             }
             my $lang = $sclient->config_value('apps', $app, 'language') || '';
-            my $max_drones = $sclient->config_value('apps', $app, 'unix_config', 'max_children') || 0;
             my $min_drones = $sclient->config_value('apps', $app, 'unix_config', 'min_children') || 0;
+            my $max_drones = $sclient->config_value('apps', $app, 'unix_config', 'max_children') || 0;
+            my $service_info = {
+                service    => $app,
+                lang       => $lang,
+                min_drones => $min_drones,
+                max_drones => $max_drones,
+            };
             if ($lang =~ /perl/i) {
-                push(@perl_services,    {service => $app, lang => $lang});
+                push(@perl_services, $service_info);
             } else {
-                push(@nonperl_services, {service => $app, lang => $lang, max_drones => $max_drones});
+                push(@nonperl_services, $service_info);
             }
         }
     }