Adding single worker handling gts.

This commit is contained in:
sergiotarxz 2024-05-06 21:49:42 +02:00
parent 6a900050a3
commit 72e7459492
2 changed files with 12 additions and 0 deletions

View File

@ -20,6 +20,7 @@ my $build = Module::Build->new(
'JSON' => 0,
'UUID::URandom' => 0,
'DateTime::Format::Mail' => 0,
'Path::Tiny' => 0,
},
);
$build->create_build_script;

View File

@ -18,6 +18,7 @@ use DateTime;
use DateTime::Format::Pg;
use JSON;
use UUID::URandom qw/create_uuid_string/;
use Path::Tiny;
use GTSRSSApi::DB;
@ -55,6 +56,16 @@ sub startup ($self) {
$r->get('/computer-all.rss')->to('Page#computer_all_rss');
$r->get('/computer-shiny.rss')->to('Page#computer_shiny_rss');
$r->get('/computer-pokerus.rss')->to('Page#computer_pokerus_rss');
my $pidfile = path('/run/gtsrssapi.pid');
my $gts_bot_pid = path('last_pid_started_gts_bot');
if (-f $pidfile) {
my $pidfile_content = $pidfile->slurp;
if ($pidfile_content eq $gts_bot_pid->slurp) {
return;
}
$gts_bot_pid->spew($pidfile_content);
}
$self->start_gts_bot;
}