1 package Catalyst::Engine::HTTP::Restarter;
5 use base 'Catalyst::Engine::HTTP';
6 use Catalyst::Engine::HTTP::Restarter::Watcher;
10 my ( $self, $class, $port, $host, $options ) = @_;
18 unless ( $restarter = fork ) {
24 my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new(
25 directory => File::Spec->catdir( $FindBin::Bin, '..' ),
26 regex => $options->{restart_regex},
27 delay => $options->{restart_delay},
31 # poll for changed files
32 my @changed_files = $watcher->watch();
34 # check if our parent process has died
35 exit if ( getppid == 1 );
37 # Restart if any files have changed
38 if ( @changed_files ) {
39 my $files = join ', ', @changed_files;
40 print STDERR qq/File(s) "$files" modified, restarting\n\n/;
47 return $self->NEXT::run( $class, $port, $host, $options );
55 Catalyst::Engine::HTTP::Restarter - Catalyst Auto-Restarting HTTP Engine
59 script/myapp_server.pl -restart
63 The Restarter engine will monitor files in your application for changes
64 and restart the server when any changes are detected.
76 L<Catalyst>, L<Catalyst::Engine::HTTP>, L<Catalyst::Engine::CGI>,
81 Sebastian Riedel, <sri@cpan.org>
83 Dan Kubb, <dan.kubb-cpan@onautopilot.com>
85 Andy Grundman, <andy@hybridized.org>
89 Many parts are ripped out of C<HTTP::Server::Simple> by Jesse Vincent.
93 This program is free software, you can redistribute it and/or modify it under
94 the same terms as Perl itself.