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__
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;