Catalyst-Helper-InitScript-FreeBSD

 view release on metacpan or  search on metacpan

lib/Catalyst/Helper/InitScript/FreeBSD.pm  view on Meta::CPAN

    -n -nproc      specify number of processes to keep to serve requests. 
                   [default is $vars->{nproc}]
       -mysql      run after init mysql. [default is no]
       -postgresql run after init postgresql. [default is no]
USAGE
}

sub _ask_overwite {
    my ($class, $vars, $output) = @_;

    prompt('y', "$output is exist. overwrite?", "", "");
}

sub _render_file {
    my ($class, $helper, $vars, $output) = @_;

    my $file = 'init_script';

    my $t = Template->new;
    my $template = $helper->get_file( __PACKAGE__, $file );
    return 0 unless $template;
    $t->process( \$template, $vars, $output )
    || Catalyst::Exception->throw(
        message => qq/Couldn't process "$file", / . $t->error() );

    return 1;
}

=head1 AUTHOR

Tomohiro Hosaka, C<< <bokutin at cpan.org> >>

=head1 COPYRIGHT & LICENSE

Copyright 2008 Tomohiro Hosaka, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1; # End of Catalyst::Helper::InitScript::FreeBSD

__DATA__

__init_script__
#!/bin/sh

# PROVIDE: [% app %]
# REQUIRE: DAEMON[% mysql ? ' mysql' : '' %][% postgresql ? ' postgresql': '' %]
# KEYWORD: shutdown

[% app %]_enable=${[% app %]_enable-"NO"}
[% app %]_flags=${[% app %]_flags-""}
[% app %]_pidfile="/var/run/[% app %].pid"
[% app %]_chdir="[% base %]"
[% app %]_user="[% user %]"
[% app %]_group="[% group %]"

[% IF use_socket %]
if [ ! -w $[% app %]_pidfile ]; then
	echo "ERROR: $[% app %]_pidfile is not writable."
	exit 1
fi
[% END %]

. /etc/rc.subr

name="[% app %]"
rcvar=`set_rcvar`
command="$[% app %]_chdir/script/[% app %]_fastcgi.pl"
command_args="-listen [% listen %] -nproc [% nproc %] -pidfile $[% app %]_pidfile -daemon"

load_rc_config $name

procname="perl-fcgi-pm"
pidfile="$[% app %]_pidfile"

run_rc_command "$1"



( run in 0.804 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )