Index: /trunk/bin/bkmkd
===================================================================
--- /trunk/bin/bkmkd	(revision 109)
+++ /trunk/bin/bkmkd	(revision 110)
@@ -18,20 +18,37 @@
 -e $CONFIG_FILE or die "Config file $CONFIG_FILE not found\n";
 my $config = YAML::LoadFile($CONFIG_FILE);
-my $command = shift or die "Usage: $0 <start|stop>\n";
 
 my %run = (
-    start   => \&_start_server,
-    stop    => \&_stop_server,
+    run     => \&run_server,
+    start   => \&start_server,
+    stop    => \&stop_server,
     restart => sub {
         my $config = shift;
-        _stop_server($config);
-        _start_server($config);
+        stop_server($config);
+        start_server($config);
     },
 );
+
+my $command = shift or die "Usage: $0 <" . join('|', keys %run) . ">\n";
 
 exists $run{$command} or die "Unrecognized command $command\n";
 $run{$command}->($config);
 
-sub _start_server {
+sub run_server {
+    my $config = shift;
+    require BookmarksApp;
+    my $app = BookmarksApp->new({ config => $config })->to_app;
+
+    my $server_root = $config->{server_root} || '.';
+    my $listen      = ':' . ($config->{port} || 5000);
+
+    my $runner = Plack::Runner->new(server => 'Starman');
+    $runner->parse_options(
+        '--listen',     $listen,
+    );
+    $runner->run($app);
+}
+
+sub start_server {
     my $config = shift;
     require BookmarksApp;
@@ -55,5 +72,5 @@
 }
 
-sub _stop_server {
+sub stop_server {
     my $config = shift;
     my $server_root = $config->{server_root} || '.';
