cualsea/cualsea-server/bin/cualsead

40 lines
646 B
Perl
Executable File

#!/usr/bin/env perl
use v5.30.0;
use strict;
use warnings;
use Carp qw/confess/;
use POSIX qw/WNOHANG/;
use Try::Tiny;
use Cualsea::Server::Loop;
use Cualsea::Server::MonitorController;
my $pid = fork;
if ($pid) {{
local $SIG{INT} = \&finish_parent;
while (1) {
my $loop = Cualsea::Server::Loop->new;
try {
$loop->run;
} catch {
confess $_;
};
}
finish_parent();
}}
my $monitor_controller = Cualsea::Server::MonitorController->new;
while (1) {
$monitor_controller->loop;
}
sub finish_parent {
kill 'INT', $pid;
1 while waitpid $pid, WNOHANG;
exit;
}