blob: be7431fc5bb10f3f6f007c31623a11efde9a2a26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package Travelynx::Command::worker;
# Copyright (C) 2020-2023 Birte Kristina Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
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(
36000 => 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 10 hours.
|