| 1 | # ABSTRACT: Another helper for 'hid publish -A' | ||||||||||
| 2 | |||||||||||
| 3 | |||||||||||
| 4 | package HiD::Server::Loader; | ||||||||||
| 5 | 6 | our $AUTHORITY = 'cpan:GENEHACK'; | |||||||||
| 6 | 6 | $HiD::Server::Loader::VERSION = '1.96'; | |||||||||
| 7 | 6 | ▶ | use 5.014; # strict, unicode_strings | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 6 | ▶ | use parent 'Plack::Loader::Restarter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | # FIXME this is kinda not the greatest idea but this is less re-implementation | ||||||||||
| 13 | # than overriding the 'run' method and there really are zero hooks provided | ||||||||||
| 14 | # for this... | ||||||||||
| 15 | sub _fork_and_start { | ||||||||||
| 16 | 0 | ▶ | my($self, $server) = @_; | ||||||||
|
Subroutine
_fork_and_start: not called CC=3 SCAR=24.8
| |||||||||||
| 17 | |||||||||||
| 18 | 0 | delete $self->{pid}; # re-init in case it's a restart | |||||||||
| 19 | |||||||||||
| 20 | 0 | my $pid = fork; | |||||||||
| 21 | 0 | ▶ | die "Can't fork: $!" unless defined $pid; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | if ($pid == 0) { # child | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $server->republish(); | |||||||||
| 25 | |||||||||||
| 26 | 0 | return $server->run($self->{builder}->()); | |||||||||
| 27 | } | ||||||||||
| 28 | else { | ||||||||||
| 29 | 0 | $self->{pid} = $pid; | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 6 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||
| 36 | |||||||||||
| 37 | =pod | ||||||||||
| 38 | |||||||||||
| 39 | =encoding UTF-8 | ||||||||||
| 40 | |||||||||||
| 41 | =head1 NAME | ||||||||||
| 42 | |||||||||||
| 43 | HiD::Server::Loader - Another helper for 'hid publish -A' | ||||||||||
| 44 | |||||||||||
| 45 | =head1 | ||||||||||
| 46 | |||||||||||
| 47 | Another helper for C<hid publish -A> | ||||||||||
| 48 | |||||||||||
| 49 | =head1 VERSION | ||||||||||
| 50 | |||||||||||
| 51 | version 1.96 | ||||||||||
| 52 | |||||||||||
| 53 | =head1 AUTHOR | ||||||||||
| 54 | |||||||||||
| 55 | John SJ Anderson <genehack@genehack.org> | ||||||||||
| 56 | |||||||||||
| 57 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 58 | |||||||||||
| 59 | This software is copyright (c) 2015 by John SJ Anderson. | ||||||||||
| 60 | |||||||||||
| 61 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 62 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 63 | |||||||||||
| 64 | =cut | ||||||||||