Changeset 94 in bookmarks for trunk


Ignore:
Timestamp:
06/06/15 00:17:55 (9 years ago)
Author:
peter
Message:

start script:

  • config file is given in a --file|-f switch
  • read the port to listen on from the config file (port setting); still defaults to 5000
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/start

    r93 r94  
    55use lib "$FindBin::RealBin/lib"; 
    66 
     7use Getopt::Long; 
     8use YAML; 
    79use Plack::Runner; 
    810use BookmarksApp; 
    911 
    10 my $CONFIG_FILE = shift || 'conf.yml'; 
    11 my $app = BookmarksApp->new({ config_file => $CONFIG_FILE })->to_app; 
     12GetOptions( 
     13    'file=s' => \my $CONFIG_FILE, 
     14); 
     15 
     16$CONFIG_FILE ||= 'conf.yml'; 
     17-e $CONFIG_FILE or die "Config file $CONFIG_FILE not found\n"; 
     18my $config = YAML::LoadFile($CONFIG_FILE); 
     19my $app = BookmarksApp->new({ config => $config })->to_app; 
     20 
     21my $listen = ':' . ($config->{port} || 5000); 
    1222 
    1323my $runner = Plack::Runner->new(server => 'Starman'); 
    14 $runner->parse_options(qw{--listen :5000 --daemonize --pid pid --error-log errors --access-log access}); 
     24$runner->parse_options(qw{--listen}, $listen, qw{--daemonize --pid pid --error-log errors --access-log access}); 
    1525$runner->run($app); 
Note: See TracChangeset for help on using the changeset viewer.