App-Munner

 view release on metacpan or  search on metacpan

lib/App/Munner/Runner.pm  view on Meta::CPAN

            directory   => $self->base_dir,
            program     => $cmd,
            pid_file    => $self->pid_file,
            stderr_file => $self->error_log,
            stdout_file => $self->access_log,
            fork        => $self->fork_mode,
            uid         => $info->{uid},
            gid         => $info->{gid},
        }
    );

    return $daemon;
}

sub run {
    my $self = shift;
    $self->_daemon->do_foreground;
}

sub run_at_bg {
    my $self   = shift;
    my $daemon = $self->_daemon;
    $daemon->do_start;
}

sub stop {
    my $self = shift;
    $self->_daemon->do_stop;
}

sub restart {
    my $self = shift;
    $self->_daemon->do_restart;
}

sub graceful {
    my $self = shift;
    $self->_daemon->do_reload;
}

has config_file => (
    is       => "ro",
    isa      => "Str",
    required => 1,
);

sub status {
    my $self = shift;
    $self->_daemon->do_status;
}

sub _set_file_permission {
    my $self = shift;
    my $file = shift
        or die "FIXME: Missing file name";
    die "FIXME: file is not found"
        if !-f $file;
    my $info = $self->sys_user_info;
    my $uid  = $info->{uid};
    my $gid  = $info->{gid};
    chown $uid, $gid, $file
        or die "Unable to chown $file\n";
    chmod 0700, $file
        or die "Unable to chown $file to 0700\n";
}

sub _touch {
    my $self = shift;
    my $file = shift;
    open my $FH, ">>", $file
        or die "Unable to touch file $file because $!\n";
    print $FH q{};
    close $FH;
    $self->_set_file_permission($file);
    my $app = $self->name;
    return $file;
}

1;



( run in 0.949 second using v1.01-cache-2.11-cpan-71847e10f99 )