- Timestamp:
- 11/16/15 17:38:47 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/bkmkd
r104 r110 18 18 -e $CONFIG_FILE or die "Config file $CONFIG_FILE not found\n"; 19 19 my $config = YAML::LoadFile($CONFIG_FILE); 20 my $command = shift or die "Usage: $0 <start|stop>\n";21 20 22 21 my %run = ( 23 start => \&_start_server, 24 stop => \&_stop_server, 22 run => \&run_server, 23 start => \&start_server, 24 stop => \&stop_server, 25 25 restart => sub { 26 26 my $config = shift; 27 _stop_server($config);28 _start_server($config);27 stop_server($config); 28 start_server($config); 29 29 }, 30 30 ); 31 32 my $command = shift or die "Usage: $0 <" . join('|', keys %run) . ">\n"; 31 33 32 34 exists $run{$command} or die "Unrecognized command $command\n"; 33 35 $run{$command}->($config); 34 36 35 sub _start_server { 37 sub run_server { 38 my $config = shift; 39 require BookmarksApp; 40 my $app = BookmarksApp->new({ config => $config })->to_app; 41 42 my $server_root = $config->{server_root} || '.'; 43 my $listen = ':' . ($config->{port} || 5000); 44 45 my $runner = Plack::Runner->new(server => 'Starman'); 46 $runner->parse_options( 47 '--listen', $listen, 48 ); 49 $runner->run($app); 50 } 51 52 sub start_server { 36 53 my $config = shift; 37 54 require BookmarksApp; … … 55 72 } 56 73 57 sub _stop_server {74 sub stop_server { 58 75 my $config = shift; 59 76 my $server_root = $config->{server_root} || '.';
Note: See TracChangeset
for help on using the changeset viewer.