From: Chris Cormack Date: Wed, 28 Aug 2013 00:07:09 +0000 (+1200) Subject: Server now starts, and uses the config X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=51637c9b91ab800a180500bd7cc35bca63b00cdb;p=working%2FNCIPServer.git Server now starts, and uses the config Signed-off-by: Jason Stephenson --- diff --git a/lib/NCIPServer.pm b/lib/NCIPServer.pm index 6cfab2a..d8928ed 100644 --- a/lib/NCIPServer.pm +++ b/lib/NCIPServer.pm @@ -1,14 +1,31 @@ package NCIPServer; use Modern::Perl; +use NCIP::Configuration; -require Net::Server::PreFork;; - -our @ISA = qw(Net::Server::PreFork); +use base qw(Net::Server::PreFork); our $VERSION = '0.01'; +sub configure_hook { + my ($self) = @_; + my $server = $self->{'server'}; + my $config = NCIP::Configuration->new( $server->{'config_dir'} ); + my $server_params = $config->('NCIP.server-params'); + while ( my ( $key, $val ) = each %$server_params ) { + $server->{$key} = $val; + } + my $listeners = $config->('NCIP.listeners'); + foreach my $svc ( keys %$listeners ) { + $server->{'port'} = $listeners->{$svc}->{'port'}; + } +} +sub post_configure_hook { + my $self = shift; + use Data::Dumper; + print Dumper $self; +} 1; __END__ diff --git a/t/NCIPServer.t b/t/NCIPServer.t index dd270dc..22ca4e0 100644 --- a/t/NCIPServer.t +++ b/t/NCIPServer.t @@ -3,7 +3,13 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 2; BEGIN { use_ok('NCIPServer') }; +ok(my $server = NCIPServer->new({config_dir => '../t/config_sample'})); +use Data::Dumper; +print Dumper $server; +$server->run(); + +print Dumper $server; diff --git a/t/config_sample/NCIP.xml b/t/config_sample/NCIP.xml index 7fc02e2..04d6b05 100644 --- a/t/config_sample/NCIP.xml +++ b/t/config_sample/NCIP.xml @@ -3,13 +3,18 @@ +