Changeset 13322

Show
Ignore:
Timestamp:
06/06/08 11:31:45 (5 years ago)
Author:
kan
Message:

add config file option
add sample config file
add daemon mode

Location:
lang/perl/XIRCD/trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/XIRCD/trunk/lib/XIRCD.pm

    r11891 r13322  
    66 
    77use POE; 
    8 use Config::Pit; 
     8use POE::Component::TSTP; 
    99use UNIVERSAL::require; 
     10use Getopt::Long; 
     11use YAML; 
    1012 
    1113use XIRCD::Server; 
     14 
    1215 
    1316sub bootstrap { 
    1417    my $class = shift; 
    1518 
    16     my $config = $class->_load_conf; 
     19    GetOptions('--config=s' => \my $conf, '--quiet' => \my $quiet); 
     20    $conf or die "Usage: xircd.pl --config=config.yaml\n"; 
     21 
     22    my $config = YAML::LoadFile($conf) or die $!; 
     23 
     24    if ($quiet) { 
     25        close STDIN; 
     26        close STDOUT; 
     27        close STDERR; 
     28        exit if fork; 
     29    } else { 
     30        # for Ctrl-Z 
     31        POE::Component::TSTP->create(); 
     32    } 
    1733 
    1834    XIRCD::Server->new( %{$config->{ircd}} ); 
     
    2945 
    3046    POE::Kernel->run; 
    31 } 
    32  
    33 sub _load_conf { 
    34     return pit_get( 
    35         'XIRCD', require => { 
    36             ircd => { 
    37                 port            => 6667, 
    38                 server_nick     => 'xircd', 
    39                 client_encoding => 'utf-8', 
    40                 no_nick_tweaks  => 1, 
    41             }, 
    42             components => [ 
    43                 { module => 'Time', nick => 'timer' }, 
    44             ], 
    45         } 
    46     ); 
    4747} 
    4848