2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
namespace App\Console;
|
|
|
|
|
2021-05-26 11:51:04 +02:00
|
|
|
use App\Jobs\Cron\AutoBillCron;
|
2021-08-24 13:59:21 +02:00
|
|
|
use App\Jobs\Cron\RecurringExpensesCron;
|
2020-03-07 23:15:11 +01:00
|
|
|
use App\Jobs\Cron\RecurringInvoicesCron;
|
2021-05-26 11:51:04 +02:00
|
|
|
use App\Jobs\Cron\SubscriptionCron;
|
2022-05-06 00:40:34 +02:00
|
|
|
use App\Jobs\Ledger\LedgerBalanceUpdate;
|
2020-05-04 23:54:24 +02:00
|
|
|
use App\Jobs\Ninja\AdjustEmailQuota;
|
2022-08-12 05:41:55 +02:00
|
|
|
use App\Jobs\Ninja\BankTransactionSync;
|
2020-07-05 10:59:28 +02:00
|
|
|
use App\Jobs\Ninja\CompanySizeCheck;
|
2022-05-15 12:43:50 +02:00
|
|
|
use App\Jobs\Ninja\QueueSize;
|
2022-05-19 12:39:02 +02:00
|
|
|
use App\Jobs\Ninja\SystemMaintenance;
|
2022-05-19 00:33:38 +02:00
|
|
|
use App\Jobs\Ninja\TaskScheduler;
|
2022-11-15 11:25:34 +01:00
|
|
|
use App\Jobs\Quote\QuoteCheckExpired;
|
2022-12-20 12:32:13 +01:00
|
|
|
use App\Jobs\Subscription\CleanStaleInvoiceOrder;
|
2021-06-07 00:41:04 +02:00
|
|
|
use App\Jobs\Util\DiskCleanup;
|
2020-04-15 02:30:52 +02:00
|
|
|
use App\Jobs\Util\ReminderJob;
|
2021-01-23 05:52:54 +01:00
|
|
|
use App\Jobs\Util\SchedulerCheck;
|
2020-04-30 13:45:47 +02:00
|
|
|
use App\Jobs\Util\SendFailedEmails;
|
2020-05-12 11:56:30 +02:00
|
|
|
use App\Jobs\Util\UpdateExchangeRates;
|
2020-03-07 23:15:11 +01:00
|
|
|
use App\Jobs\Util\VersionCheck;
|
2021-10-08 12:06:24 +02:00
|
|
|
use App\Models\Account;
|
2020-03-25 14:03:23 +01:00
|
|
|
use App\Utils\Ninja;
|
2018-10-04 19:10:43 +02:00
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
|
|
|
|
class Kernel extends ConsoleKernel
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Define the application's command schedule.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param Schedule $schedule
|
2018-10-04 19:10:43 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function schedule(Schedule $schedule)
|
|
|
|
{
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Check for the latest version of Invoice Ninja */
|
2021-03-23 13:17:28 +01:00
|
|
|
$schedule->job(new VersionCheck)->daily();
|
2020-03-23 18:15:56 +01:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Checks and cleans redundant files */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new DiskCleanup)->dailyAt('02:10')->withoutOverlapping()->name('disk-cleanup-job')->onOneServer();
|
2021-06-07 00:41:04 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Send reminders */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new ReminderJob)->hourly()->withoutOverlapping()->name('reminder-job')->onOneServer();
|
2020-05-12 11:56:30 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Returns the number of jobs in the queue */
|
2022-11-26 04:38:09 +01:00
|
|
|
$schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping()->name('queue-size-job')->onOneServer();
|
2022-05-06 00:40:34 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Checks for large companies and marked them as is_large */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new CompanySizeCheck)->dailyAt('23:20')->withoutOverlapping()->name('company-size-job')->onOneServer();
|
2020-07-05 10:59:28 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Pulls in the latest exchange rates */
|
2022-11-26 04:38:09 +01:00
|
|
|
$schedule->job(new UpdateExchangeRates)->dailyAt('23:30')->withoutOverlapping()->name('exchange-rate-job')->onOneServer();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Runs cleanup code for subscriptions */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new SubscriptionCron)->dailyAt('00:01')->withoutOverlapping()->name('subscription-job')->onOneServer();
|
2021-03-05 11:18:28 +01:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Sends recurring invoices*/
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new RecurringInvoicesCron)->hourly()->withoutOverlapping()->name('recurring-invoice-job')->onOneServer();
|
2021-08-24 13:59:21 +02:00
|
|
|
|
2022-12-20 12:32:13 +01:00
|
|
|
/* Stale Invoice Cleanup*/
|
|
|
|
$schedule->job(new CleanStaleInvoiceOrder)->hourly()->withoutOverlapping()->name('stale-invoice-job')->onOneServer();
|
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Sends recurring invoices*/
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new RecurringExpensesCron)->dailyAt('00:10')->withoutOverlapping()->name('recurring-expense-job')->onOneServer();
|
2021-08-24 13:59:21 +02:00
|
|
|
|
2022-11-15 11:25:34 +01:00
|
|
|
/* Fires notifications for expired Quotes */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new QuoteCheckExpired)->dailyAt('05:10')->withoutOverlapping()->name('quote-expired-job')->onOneServer();
|
2022-11-15 11:25:34 +01:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Performs auto billing */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new AutoBillCron)->dailyAt('06:20')->withoutOverlapping()->name('auto-bill-job')->onOneServer();
|
2021-05-26 11:51:04 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Checks the status of the scheduler */
|
2022-11-25 21:29:15 +01:00
|
|
|
$schedule->job(new SchedulerCheck)->dailyAt('01:10')->withoutOverlapping();
|
2020-09-08 12:34:14 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Checks for scheduled tasks */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new TaskScheduler())->dailyAt('06:50')->withoutOverlapping()->name('task-scheduler-job')->onOneServer();
|
2022-05-19 00:33:38 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Performs system maintenance such as pruning the backup table */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new SystemMaintenance)->sundays()->at('02:30')->withoutOverlapping()->name('system-maintenance-job')->onOneServer();
|
2022-05-27 05:10:32 +02:00
|
|
|
|
2022-08-16 01:53:22 +02:00
|
|
|
/* Pulls in bank transactions from third party services */
|
2022-11-26 02:38:09 +01:00
|
|
|
$schedule->job(new BankTransactionSync)->dailyAt('04:10')->withoutOverlapping()->name('bank-trans-sync-job')->onOneServer();
|
2022-08-12 05:41:55 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (Ninja::isSelfHost()) {
|
2022-08-16 01:53:22 +02:00
|
|
|
|
2021-10-08 12:06:24 +02:00
|
|
|
$schedule->call(function () {
|
|
|
|
Account::whereNotNull('id')->update(['is_scheduler_running' => true]);
|
2022-05-19 00:33:38 +02:00
|
|
|
})->everyFiveMinutes();
|
2022-08-16 01:53:22 +02:00
|
|
|
|
2021-10-17 04:49:32 +02:00
|
|
|
}
|
2021-10-08 12:06:24 +02:00
|
|
|
|
2020-04-30 13:45:47 +02:00
|
|
|
/* Run hosted specific jobs */
|
2020-09-06 11:38:10 +02:00
|
|
|
if (Ninja::isHosted()) {
|
2022-08-16 01:53:22 +02:00
|
|
|
|
2021-12-17 08:04:34 +01:00
|
|
|
$schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping();
|
|
|
|
|
2022-11-11 00:13:11 +01:00
|
|
|
//not used @deprecate
|
|
|
|
// $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
|
2021-12-17 08:04:34 +01:00
|
|
|
|
2022-11-26 21:52:49 +01:00
|
|
|
$schedule->command('ninja:check-data --database=db-ninja-01')->dailyAt('02:10')->withoutOverlapping()->name('check-data-db-1-job')->onOneServer();
|
2021-12-17 08:04:34 +01:00
|
|
|
|
2022-11-26 21:52:49 +01:00
|
|
|
$schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('02:20')->withoutOverlapping()->name('check-data-db-2-job')->onOneServer();
|
2021-12-17 08:04:34 +01:00
|
|
|
|
2022-11-26 21:52:49 +01:00
|
|
|
$schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping()->name('s3-cleanup-job')->onOneServer();
|
2022-08-16 01:53:22 +02:00
|
|
|
|
2020-04-30 13:45:47 +02:00
|
|
|
}
|
2021-03-19 13:37:57 +01:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && ! config('ninja.is_docker')) {
|
2022-08-16 01:53:22 +02:00
|
|
|
|
2022-06-04 10:38:04 +02:00
|
|
|
$schedule->command('queue:work database --stop-when-empty --memory=256')->everyMinute()->withoutOverlapping();
|
2021-12-17 08:04:34 +01:00
|
|
|
|
2022-05-19 00:33:38 +02:00
|
|
|
$schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping();
|
2022-08-16 01:53:22 +02:00
|
|
|
|
2021-04-17 23:06:12 +02:00
|
|
|
}
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the commands for the application.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function commands()
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
$this->load(__DIR__.'/Commands');
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
require base_path('routes/console.php');
|
|
|
|
}
|
|
|
|
}
|