POE::Component::Server::Postfix::UNIX - POE::Component::Server::Postfix::UNIX documentation


POE-Component-Server-Postfix documentation Contained in the POE-Component-Server-Postfix distribution.

Index


Code Index:

NAME

Top

POE::Component::Server::Postfix::UNIX

VERSION

Top

version 0.001

METHODS

Top

socketfactory_args

AUTHOR

Top

  Hans Dieter Pearcey <hdp@cpan.org>

COPYRIGHT AND LICENSE

Top


POE-Component-Server-Postfix documentation Contained in the POE-Component-Server-Postfix distribution.

use strict;
use warnings;

package POE::Component::Server::Postfix::UNIX;
our $VERSION = '0.001';


use MooseX::POE;
extends 'POE::Component::Server::Postfix';

has path => (is => 'ro', isa => 'Str', required => 1);
has mode => (is => 'ro', default => 0755);


sub socketfactory_args {
  my ($self) = @_;
  return (
    SocketDomain => Socket::AF_UNIX,
    BindAddress  => $self->path,
  );
}

sub _unlink {
  my ($self) = @_;
  if (-e $self->path) {
    unlink $self->path or die "Can't unlink " . $self->path . ": $!";
  }
}

sub _build_server {
  my ($self) = @_;
  $self->_unlink;
  my $server = $self->SUPER::_build_server;
  chmod $self->mode, $self->path or die "Can't chmod " . $self->path . ": $!";
  return $server;
}

sub STOP { shift->_unlink }

1;

__END__