Beekeeper
view release on metacpan or search on metacpan
examples/chat/lib/MyApp/Client.pm view on Meta::CPAN
print $msg{message} . "\n";
});
if ($ARGV[-1] && $ARGV[-1] eq '--test') {
$self->run_tests;
exit;
}
$self->{hdl} = AnyEvent::Handle->new( fh => $self->{fh} );
$self->{auth}->login( username => getpwuid($>), password => '123' );
$self->read_line;
$self->{quit_cv} = AnyEvent->condvar;
$self->{quit_cv}->recv;
}
sub read_line {
my $self = shift;
lib/Beekeeper/Logger.pm view on Meta::CPAN
my $service = lc $self->{worker_class};
$service =~ s/::/-/g;
$service =~ s/-worker$//;
$self->{service} = $service;
}
unless ($self->{log_file}) {
# Use a single log file per service
my $dir = '/var/log';
my $user = getpwuid($>);
my $file = $self->{service} . '.log';
($user) = ($user =~ m/(\w+)/); # untaint
$self->{log_file} = (-d "$dir/$user") ? "$dir/$user/$file" : "$dir/$file";
}
unless ($self->{foreground}) {
my $log_file = $self->{log_file};
lib/Beekeeper/WorkerPool.pm view on Meta::CPAN
$self->{config}->{'pool_id'} = $pool_id;
$self->{config}->{daemon_name} = "beekeeper-$pool_id";
$self->{config}->{description} = "worker pool $pool_id";
# Pool cannot be started without a proper config file
$self->load_config || CORE::exit(1);
unless ($self->{config}->{log_file}) {
my $file = "$pool_id-pool.log";
my $dir = '/var/log';
my $user = $self->{options}->{'user'} || getpwuid($>);
($user) = ($user =~ m/^(\w+)$/); # untaint
$self->{config}->{log_file} = (-d "$dir/$user") ? "$dir/$user/$file" : "$dir/$file";
}
return $self;
}
sub cmd_help {
my $self = shift;
lib/Beekeeper/WorkerPool/Daemon.pm view on Meta::CPAN
}
sub redirect_output {
my $self = shift;
my $logfile = $self->{config}->{log_file};
unless ($logfile) {
my $dir = $LOG_FILE_DIR;
my $user = getpwuid($<);
my $file = $self->daemon_name . '.log';
$logfile = (-d "$dir/$user") ? "$dir/$user/$file" : "$dir/$file";
}
die unless ($logfile =~ m/\.log$/);
open(LOG, '>>', $logfile) or die("Can't open log file '$logfile': $!");
open(STDERR, '>&', \*LOG) or (print "Can't redirect STDERR to log file: $!" && CORE::exit(1));
open(STDOUT, '>&', \*LOG) or die("Can't redirect STDOUT to log file: $!");
lib/Beekeeper/WorkerPool/Daemon.pm view on Meta::CPAN
# PIDFILE HANDLING
sub pid_file {
my $self = shift;
my $pidfile = $self->{config}->{pidfile};
unless ($pidfile) {
my $dir = $PID_FILE_DIR;
my $user = getpwuid($<);
my $file = $self->daemon_name . '.pid';
$pidfile = (-d "$dir/$user") ? "$dir/$user/$file" : "$dir/$file";
}
return $pidfile;
}
sub write_pid_file {
my $self = shift;
my $pidfile = $self->pid_file;
( run in 0.310 second using v1.01-cache-2.11-cpan-8d75d55dd25 )