worker: run maintenance every 10 hours

This commit is contained in:
Daniel Friesel 2022-02-19 16:32:43 +01:00
parent 8ec78343e7
commit 15b510de32
No known key found for this signature in database
GPG key ID: 100D5BFB5166E005

View file

@ -1,27 +1,31 @@
package Travelynx::Command::worker;
# Copyright (C) 2020 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
use Mojo::Base 'Mojolicious::Command';
use Mojo::IOLoop;
has description =>
'travelynx background worker';
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(
180 => sub {
$self->app->start('work');
}
);
Mojo::IOLoop->recurring(3600 => sub {
$self->app->start('maintenance');
});
Mojo::IOLoop->recurring(
36000 => sub {
$self->app->start('maintenance');
}
);
if (not Mojo::IOLoop->is_running) {
if ( not Mojo::IOLoop->is_running ) {
Mojo::IOLoop->start;
}
}
@ -36,4 +40,4 @@ __END__
Background worker for cron-less setups, e.g. Docker.
Calls "index.pl work" every 3 minutes and "index.pl maintenance" every 1 hour.
Calls "index.pl work" every 3 minutes and "index.pl maintenance" every 10 hours.