actually load config
[scpubgit/Clifton.git] / lib / App / Clifton / Server.pm
CommitLineData
20038dd8 1package App::Clifton::Server;
2
3use aliased 'App::Clifton::ServiceContainer';
4use aliased 'App::Clifton::ConfigLoader';
5use Moo;
6
7extends 'App::Clifton::Service';
8
9sub BUILD {
10 my ($self, $args) = @_;
11 $args->{loop}->add($self);
12 $self->$_ for qw(services);
13}
14
15has config_file => (is => 'ro', required => 1);
16
17has config_loader => (is => 'lazy');
18
46b150cd 19has current_config => (is => 'rw');
20
20038dd8 21sub _build_config_loader { ConfigLoader->new }
22
23has services => (is => 'lazy');
24
25sub _build_services {
26 shift->_new_child(ServiceContainer, {});
27}
28
29sub reload_config { shift->_do(reload_config => @_) }
30sub shutdown { shift->_do(shutdown => @_) }
31
32sub _body_for_reload_config {
33 my ($self, $args) = @_;
46b150cd 34 my $config = $self->config_loader->config_from_file($self->config_file);
35 $self->current_config($config);
36 $args->{on_finished}->($config);
20038dd8 37}
38
391;