BusyBird

 view release on metacpan or  search on metacpan

lib/BusyBird/Runner.pm  view on Meta::CPAN

    return ("--no-default-middleware", "-a", $config_script,
            "-o", $bind_host, "-p", $bind_port, "-s", "Twiggy");
}

sub _ensure_config_dir_exists {
    my $dir = config_directory;
    if(! -d $dir) {
        if(!mkdir $dir) {
            warn "Cannot create config directory $dir: $!\n";
            die "_check_config_dir";
        }
    }
}

sub _ensure_config_file_exists {
    my ($filepath, $create_default) = @_;
    if(! -f $filepath) {
        if($create_default) {
            _create_default_config_file($filepath);
        }else  {
            my $msg = "Cannot access config file $filepath. Maybe it does not exist.";
            warn "$msg\n";
            die $msg;
        }
    }
}

sub _create_default_config_file {
    my ($config_filepath) = @_;
    require File::ShareDir;
    require File::Copy;
    my $sample = File::Spec->catfile(File::ShareDir::dist_dir("BusyBird"), "sample_config.psgi");
    File::Copy::copy($sample, $config_filepath) or do {
        warn "Error while copying $sample to $config_filepath: $!\n";
        die "_create_default_config_file";
    };
}


1;
__END__

=pod

=head1 NAME

BusyBird::Runner - BusyBird process runner

=head1 SYNOPSIS

    #!/usr/bin/perl
    use strict;
    use warnings;
    use BusyBird::Runner qw(run);
    
    run(@ARGV);

=head1 DESCRIPTION

L<BusyBird::Runner> runs L<BusyBird> process instance.
This is the direct back-end of C<busybird> command.

=head1 EXPORTABLE FUNCTIONS

The following functions are exported only by request.

=head2 $need_help = run(@argv)

Runs the L<BusyBird> process instance.

C<@argv> is the command-line arguments. See L<busybird> for detail.

Return value C<$need_help> indicates if the user might need some help.
If C<$need_help> is non-C<undef>, the caller should provide the user with some help.

=head1 AUTHOR

Toshio Ito C<< <toshioito [at] cpan.org> >>

=cut



( run in 1.202 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )