| 1 | package XIRCD; | ||
| 2 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | with 'MooseX::Daemonize'; | ||
| 5 | |||
| 6 | our $VERSION = '0.0.1'; | ||
| 7 | |||
| 8 | 1 | ▶ | use POE; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use UNIVERSAL::require; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use YAML; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 1 | ▶ | use XIRCD::Server; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 13 | |||
| 14 | has 'config' => ( | ||
| 15 | is => 'rw', | ||
| 16 | isa => 'Str', | ||
| 17 | required => 1, | ||
| 18 | ); | ||
| 19 | |||
| 20 | has 'daemon' => ( | ||
| 21 | is => 'rw', | ||
| 22 | isa => 'Bool', | ||
| 23 | default => 0, | ||
| 24 | ); | ||
| 25 | |||
| 26 | after 'start' => sub { | ||
| 27 | my $self = shift; | ||
| 28 | return unless $self->is_daemon; | ||
| 29 | |||
| 30 | $self->bootstrap; | ||
| 31 | }; | ||
| 32 | |||
| 33 | |||
| 34 | sub bootstrap { | ||
| 35 | my $self = shift; | ||
| 36 | |||
| 37 | $self->config or die "Usage: xircd.pl --config=config.yaml\n"; | ||
| 38 | |||
| 39 | my $config = YAML::LoadFile($self->config) or die $!; | ||
| 40 | |||
| 41 | XIRCD::Server->new( %{$config->{ircd}} ); | ||
| 42 | |||
| 43 | for my $component ( @{$config->{components}} ) { | ||
| 44 | my $module = 'XIRCD::Component::' . $component->{module}; | ||
| 45 | $module->require or die $@; | ||
| 46 | $module->new( | ||
| 47 | name => lc($component->{module}), | ||
| 48 | channel => '#' . lc($component->{module}), | ||
| 49 | %{$component} | ||
| 50 | ); | ||
| 51 | } | ||
| 52 | |||
| 53 | POE::Kernel->run; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1; | ||
| 57 | __END__ | ||
| 58 | |||
| 59 | =head1 NAME | ||
| 60 | |||
| 61 | XIRCD - | ||
| 62 | |||
| 63 | =head1 SYNOPSIS | ||
| 64 | |||
| 65 | use XIRCD; | ||
| 66 | |||
| 67 | =head1 DESCRIPTION | ||
| 68 | |||
| 69 | XIRCD is | ||
| 70 | |||
| 71 | =head1 AUTHOR | ||
| 72 | |||
| 73 | Kan Fushihara E<lt>kan at mobilefactory do jpE<gt> | ||
| 74 | |||
| 75 | =head1 SEE ALSO | ||
| 76 | |||
| 77 | =head1 LICENSE | ||
| 78 | |||
| 79 | This library is free software; you can redistribute it and/or modify | ||
| 80 | it under the same terms as Perl itself. | ||
| 81 | |||
| 82 | =cut | ||