DBIx-QuickDB

 view release on metacpan or  search on metacpan

lib/DBIx/QuickDB/Watcher.pm  view on Meta::CPAN

use strict;
use warnings;

our $VERSION = '0.000065';

use Carp qw/croak/;
use Cwd qw/abs_path/;
use Errno qw/ESRCH/;
use POSIX qw/:sys_wait_h/;
use Time::HiRes qw/sleep time/;
use Scalar::Util qw/weaken/;
use File::Path qw/remove_tree/;

# Resolved at load time, not at spawn time: $INC{} can be relative, and an
# application may chdir before starting a database, which would resolve it
# against the wrong directory and hand the watcher a different Watcher.pm.
my $LOADED_FROM = do {
    my $file = $INC{'DBIx/QuickDB/Watcher.pm'};

    my $dir;
    if (defined($file) && length($file)) {

lib/DBIx/QuickDB/Watcher.pm  view on Meta::CPAN


    return;
}

sub init {
    my $self = shift;

    $self->{+MASTER_PID} ||= $$;

    # Captured up front: wait() needs it after teardown, when the DB reference
    # has been weakened and may already be gone.
    $self->{+DATA_DIR} //= $self->{+DB}->dir;

    $self->{+LOG_FILE} = $self->{+DB}->gen_log;

    $self->start();

    weaken($self->{+DB}) if $self->{+MASTER_PID} == $$;
}

sub start {
    my $self = shift;
    return if $self->{+SERVER_PID};

    my ($rh, $wh);
    pipe($rh, $wh) or die "Could not open pipe: $!";

    my $pid = fork;



( run in 0.743 second using v1.01-cache-2.11-cpan-364913b4093 )