2019-05-03 16:26:05 +00:00
|
|
|
package Travelynx::Command::worker;
|
2020-11-27 21:12:56 +00:00
|
|
|
# Copyright (C) 2020 Daniel Friesel
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2019-05-03 16:26:05 +00:00
|
|
|
use Mojo::Base 'Mojolicious::Command';
|
|
|
|
use Mojo::IOLoop;
|
|
|
|
|
|
|
|
has description =>
|
|
|
|
'travelynx background worker';
|
|
|
|
|
|
|
|
has usage => sub { shift->extract_usage };
|
|
|
|
|
|
|
|
sub run {
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
Mojo::IOLoop->recurring(180 => sub {
|
|
|
|
$self->app->start('work');
|
|
|
|
});
|
|
|
|
|
|
|
|
Mojo::IOLoop->recurring(3600 => sub {
|
|
|
|
$self->app->start('maintenance');
|
|
|
|
});
|
|
|
|
|
|
|
|
if (not Mojo::IOLoop->is_running) {
|
|
|
|
Mojo::IOLoop->start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
Usage: index.pl worker
|
|
|
|
|
|
|
|
Background worker for cron-less setups, e.g. Docker.
|
|
|
|
|
|
|
|
Calls "index.pl work" every 3 minutes and "index.pl maintenance" every 1 hour.
|