Subscribed unsubscribe Subscribe Subscribe

Hateburo: kazeburo hatenablog

Operations Engineer / Site Reliability / 運用系小姑 / Perl Monger

Starlet / How to listen to Unix Domain Socket without Server::Starter

Define $ENV{SERVER_STARTER_PORT} in your script.

if (-S $socket) {
    warn "removing existing socket file:$socket";
    unlink $socket
        or die "failed to remove existing socket file:$socket:$!";
}
unlink $socket;
my $sock = IO::Socket::UNIX->new(
    Listen => Socket::SOMAXCONN(),
    Local  => $socket,
) or die "failed to listen to file $socket:$!";
$ENV{SERVER_STARTER_PORT} = $socket."=".$sock->fileno;

my $loader = Plack::Loader->load(
    'Starlet',
    max_workers => 10,
);
$loader->run($app);