Skip to content

Commit

Permalink
removed almost everything
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Apr 1, 2010
1 parent 67c4613 commit e620bd0
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions hanger
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use warnings;
use WWW::Mechanize;

my $server = HangServer->new;
$server->background;
my $pid = $server->background;
my $server_root = $server->root;

my $mech = WWW::Mechanize->new;
Expand Down Expand Up @@ -40,7 +40,8 @@ GOOD_GET: {
print "\n\nHit enter to down the server";
$f = <>;

$server->stop;
print "Killing pid $pid\n";
kill( 9, $pid ) unless $^S;

print "Server stopped\n";

Expand All @@ -56,13 +57,9 @@ use base 'HTTP::Server::Simple::CGI';

use Carp ();

our $pid;

sub new {
my $class = shift;

die 'An instance of HangServer has already been started.' if $pid;

# XXX This should really be a random port.
return $class->SUPER::new(13432, @_);
}
Expand All @@ -80,16 +77,6 @@ sub handle_request {
return;
}

sub background {
my $self = shift;

$pid = $self->SUPER::background()
or Carp::confess( q{Can't start the test server} );

sleep 1; # background() may come back prematurely, so give it a second to fire up

return $pid;
}

sub root {
my $self = shift;
Expand All @@ -98,13 +85,4 @@ sub root {
return "http://localhost:$port";
}

sub stop {
if ( $pid ) {
kill( 9, $pid ) unless $^S;
undef $pid;
}

return;
}

1;

0 comments on commit e620bd0

Please sign in to comment.