Index: trunk/stop
===================================================================
--- trunk/stop	(revision 65)
+++ 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;
+}
