Index: /trunk/cpanfile
===================================================================
--- /trunk/cpanfile	(revision 101)
+++ /trunk/cpanfile	(revision 102)
@@ -10,4 +10,6 @@
 # web application
 requires 'Plack', '1.0036';
+requires 'Starman';
+requires 'File::Pid';
 
 # for opening the dbh handle
Index: /trunk/start
===================================================================
--- /trunk/start	(revision 101)
+++ /trunk/start	(revision 102)
@@ -9,4 +9,5 @@
 use Plack::Runner;
 use BookmarksApp;
+use File::Spec::Functions qw{catfile};
 
 GetOptions(
@@ -19,7 +20,17 @@
 my $app = BookmarksApp->new({ config => $config })->to_app;
 
-my $listen = ':' . ($config->{port} || 5000);
+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(qw{--listen}, $listen, qw{--daemonize --pid pid --error-log errors --access-log access});
+$runner->parse_options(
+    '--daemonize',
+    '--listen',     $listen,
+    '--pid',        $pid_file,
+    '--error-log',  $error_log,
+    '--access-log', $access_log,
+);
 $runner->run($app);
Index: /trunk/stop
===================================================================
--- /trunk/stop	(revision 101)
+++ /trunk/stop	(revision 102)
@@ -1,3 +1,28 @@
-#!/bin/bash
+#!/usr/bin/perl -w
+use strict;
 
-kill `cat pid`
+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;
+}
