Index: trunk/bin/bkmkd
===================================================================
--- trunk/bin/bkmkd	(revision 103)
+++ trunk/bin/bkmkd	(revision 104)
@@ -21,37 +21,10 @@
 
 my %run = (
-    start => sub {
+    start   => \&_start_server,
+    stop    => \&_stop_server,
+    restart => sub {
         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 $access_log  = catfile($server_root, 'access');
-        my $error_log   = catfile($server_root, 'errors');
-        my $pid_file    = catfile($server_root, 'pid');
-
-        my $runner = Plack::Runner->new(server => 'Starman');
-        $runner->parse_options(
-            '--daemonize',
-            '--listen',     $listen,
-            '--pid',        $pid_file,
-            '--error-log',  $error_log,
-            '--access-log', $access_log,
-        );
-        $runner->run($app);
-    },
-
-    stop => sub {
-        my $config = shift;
-        my $server_root = $config->{server_root} || '.';
-
-        my $pid_file = File::Pid->new({
-                file => catfile($server_root, 'pid'),
-            });
-
-        if (my $pid = $pid_file->running) {
-            kill 'TERM', $pid;
-        }
+        _stop_server($config);
+        _start_server($config);
     },
 );
@@ -59,2 +32,43 @@
 exists $run{$command} or die "Unrecognized command $command\n";
 $run{$command}->($config);
+
+sub _start_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 $access_log  = catfile($server_root, 'access');
+    my $error_log   = catfile($server_root, 'errors');
+    my $pid_file    = catfile($server_root, 'pid');
+
+    my $runner = Plack::Runner->new(server => 'Starman');
+    $runner->parse_options(
+        '--daemonize',
+        '--listen',     $listen,
+        '--pid',        $pid_file,
+        '--error-log',  $error_log,
+        '--access-log', $access_log,
+    );
+    $runner->run($app);
+}
+
+sub _stop_server {
+    my $config = shift;
+    my $server_root = $config->{server_root} || '.';
+
+    my $pid_path = catfile($server_root, 'pid');
+    unless (-e $pid_path) {
+        warn "$pid_path does not exist\n";
+        return;
+    }
+
+    my $pid_file = File::Pid->new({
+        file => $pid_path,
+    });
+
+    if (my $pid = $pid_file->running) {
+        kill 'TERM', $pid;
+    }
+}
Index: trunk/bin/stop
===================================================================
--- trunk/bin/stop	(revision 103)
+++ 	(revision )
@@ -1,28 +1,0 @@
-#!/usr/bin/perl -w
-use strict;
-
-use FindBin;
-use lib "$FindBin::RealBin/../lib";
-
-use Getopt::Long;
-use YAML;
-use File::Pid;
-use File::Spec::Functions qw{catfile};
-
-GetOptions(
-    'file=s' => \my $CONFIG_FILE,
-);
-
-$CONFIG_FILE ||= 'server.yml';
--e $CONFIG_FILE or die "Config file $CONFIG_FILE not found\n";
-my $config = YAML::LoadFile($CONFIG_FILE);
-
-my $server_root = $config->{server_root} || '.';
-
-my $pid_file = File::Pid->new({
-    file => catfile($server_root, 'pid'),
-});
-
-if (my $pid = $pid_file->running) {
-    kill 'TERM', $pid;
-}
