#!perl package cpanidx_httpserver; { $cpanidx_httpserver::VERSION = '0.08'; } # ABSTRACT: HTTP::Server::Simple based server for CPANIDX use strict; use warnings; use Config::Tiny; use Getopt::Long; use App::CPANIDX::HTTP::Server; my $config = 'cpanidx.ini'; my $tmport = 0; GetOptions( 'config=s', \$config, 'port=i', \$tmport ); my $ini = Config::Tiny->new(); my $port; my $dsn; my $user; my $pass; my $cfg = $ini->read( $config ) or warn $ini->errstr, "\n"; if ( $cfg ) { $port = $cfg->{_}->{port}; $dsn = $cfg->{_}->{dsn}; $user = $cfg->{_}->{user}; $pass = $cfg->{_}->{pass}; } unless ( $dsn ) { $dsn = 'dbi:SQLite:dbname=cpanidx.db'; warn "Using '$dsn'\n"; } $port = $tmport unless defined $port; my $server = App::CPANIDX::HTTP::Server->new( $port ); $server->dsn( $dsn, $user, $pass ); $server->run(); exit 0; __END__ =pod =head1 NAME cpanidx_httpserver - HTTP::Server::Simple based server for CPANIDX =head1 VERSION version 0.08 =head1 DESCRIPTION C is a L based server for L. =head1 SYNPOSIS # cpanidx.ini port=8082 dsn=dbi:SQLite:dbname=cpanidx.db $ cpanidx_httpserver --config cpanidx.ini =head1 CONFIGURATION Configuration is stored in an L style initialisation file. By default it looks for a C in the current working directory. This can be amended by using the C<--config> command line switch. If no previous configuration is found, the script will default to using L based database C in the current working directory. The following configuration options are available: =over =item C Specify the L C string to use. =item C Specify the username to use with the C (if applicable). =item C Specify the password to use with the C (if applicable). =item C Specify the listening port to use. The default is C<8080>. =back =head1 COMMAND LINE OPTIONS =over =item C<--config> Specify a configuration file to use. The default is to use C in the current working directory. =item C<--port> Specify the listening port to use. The default is C<8080>. =back =head1 AUTHOR Chris Williams =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Chris Williams. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut