e16cf6053f8be67e715f58caf946bb25c6ea4729
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / ExternalCatty.pm
1 package ExternalCatty;
2 use strict;
3 use warnings;
4 use Catalyst;
5
6 __PACKAGE__->config( name => 'ExternalCatty' );
7 __PACKAGE__->setup;
8 __PACKAGE__->setup_engine('HTTP');
9
10 # The Cat HTTP server background option is useless here :-(
11 # Thus we have to provide our own background method.
12 sub background {
13     my $self  = shift;
14     my $port  = shift;
15     my $child = fork;
16     die "Can't fork Cat HTTP server: $!" unless defined $child;
17     return $child if $child;
18
19     if ( $^O !~ /MSWin32/ ) {
20         require POSIX;
21         POSIX::setsid() or die "Can't start a new session: $!";
22     }
23
24     $self->run($port);
25 }
26
27 1;
28