Title: [opsview] [11747] Sanity check Starman options
- Revision
- 11747
- Author
- dferguson
- Date
- 2013-03-12 17:34:37 +0000 (Tue, 12 Mar 2013)
Log Message
Sanity check Starman options
If starman is given nonsense options then it accepts them and silently fails to start up.
Sanity check some options and where they are wrong, warn and reset them to allow starman to start up
Modified Paths
Modified: trunk/opsview-web/lib/Opsview/Web.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web.pm 2013-03-12 17:16:38 UTC (rev 11746)
+++ trunk/opsview-web/lib/Opsview/Web.pm 2013-03-12 17:34:37 UTC (rev 11747)
@@ -121,9 +121,42 @@
my $config = $c->config->{ProductionEngine} || {};
+ # If m(in|ax)_[spare_]servers are not set correctly then
+ # web app will not start and no error is produced
+
+ if ( $config->{max_servers} <= $config->{min_servers} ) {
+ warn
+ '"max_servers" should be greater than "min_servers" in Opsview Web configuration file',
+ $/;
+ $config->{max_servers}++;
+ warn 'Reset "max_servers" to: ', $config->{max_servers}, $/;
+ }
+
+ # add one onto min_servers as net::server code tests incorrectly for
+ # min_spare_servers - if min_servers and min_spare_servers are set
+ # to 1 then net::server tests min_spare_servers as 0 (false)
+ # so it then resets it to a default of 4 and app silently dies
+ if ( $config->{min_spare_servers} >= $config->{min_servers} ) {
+ warn
+ '"min_spare_servers" must be less than "min_servers" in Opsview Web configuration file',
+ $/;
+ $config->{min_servers}++;
+ warn 'Reset "min_servers" to: ', $config->{min_servers}, $/;
+ }
+
+ # same happens with max_servers and max_spare_servers
+ if ( $config->{max_spare_servers} >= $config->{max_servers} ) {
+ warn
+ '"max_spare_servers" must be less than "max_servers" in Opsview Web configuration file',
+ $/;
+ $config->{max_spare_servers} = $config->{max_servers} - 1;
+ warn 'Reset "max_spare_servers" to: ', $config->{max_spare_servers},
+ $/;
+ }
+
# We allow all keys to pass through from the yml file for the moment, as it is unclear how Starman treats some of these
#foreach my $key (qw(host port workers max-requests max_requests min_servers max_servers min_spare_servers max_spare_servers backlog)) {
- foreach my $key (%$config) {
+ foreach my $key ( keys(%$config) ) {
$options->{$key} = $config->{$key};
}
_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins