mirror of
https://github.com/derf/travelynx
synced 2024-12-02 01:09:11 +00:00
worker: run maintenance every 10 hours
This commit is contained in:
parent
8ec78343e7
commit
15b510de32
1 changed files with 14 additions and 10 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue