TT#34022 write READY=1 to notify socket

Change-Id: I6d24a1f76ea150e069f7c6ea9c344dd37945b386
changes/31/19731/6
Rene Krenn 8 years ago
parent 06f167be0e
commit f54c69ecfd

@ -6,7 +6,7 @@ Requires=network.target
Requires=mariadb.service
[Service]
Type=simple
Type=notify
EnvironmentFile=/etc/default/ngcp-panel
Environment="HOME=/usr/share/ngcp-panel"
User=www-data

@ -4,6 +4,7 @@ use Moose;
use Catalyst::Runtime 5.80;
use File::Slurp qw();
use Config::General qw();
use IO::Socket::UNIX qw(SOCK_DGRAM);
# Set flags and add plugins for the application.
#
@ -265,6 +266,27 @@ __PACKAGE__->log(Log::Log4perl::Catalyst->new($logger_config));
}
}
after setup_finalize => sub {
my $app = shift;
if ($ENV{NOTIFY_SOCKET}) {
my $addr = $ENV{NOTIFY_SOCKET} =~ s/^@/\0/r;
my $client = IO::Socket::UNIX->new(
Type => SOCK_DGRAM(),
Peer => $addr,
) or warn("can't connect to socket $ENV{NOTIFY_SOCKET}: $!\n");
if ($client) {
$client->autoflush(1);
print $client "READY=1\n" or warn("can't send to socket $ENV{NOTIFY_SOCKET}: $!\n");
close $client;
}
} else {
warn("NOTIFY_SOCKET not set\n");
}
};
# Start the application
__PACKAGE__->setup();

Loading…
Cancel
Save