Lae/app/Console/Kernel.php

71 lines
2.1 KiB
PHP
Raw Normal View History

2022-08-12 07:56:56 +00:00
<?php
namespace App\Console;
2022-11-19 04:37:18 +00:00
use App\Jobs\AutoCloseWorkOrder;
2022-11-08 13:01:43 +00:00
use App\Jobs\CheckAndChargeBalance;
use App\Jobs\CheckHostIfExistsOnModule;
2022-09-03 05:22:40 +00:00
use App\Jobs\ClearTasks;
2022-09-03 06:01:51 +00:00
use App\Jobs\DeleteHost;
2022-11-08 13:01:43 +00:00
use App\Jobs\HostCost;
2022-11-16 02:29:50 +00:00
use App\Jobs\Module\FetchModule;
use App\Jobs\Module\PushWorkOrder;
2022-11-19 04:37:18 +00:00
use App\Jobs\SendModuleEarnings;
2022-08-12 07:56:56 +00:00
use Illuminate\Console\Scheduling\Schedule;
2022-11-06 11:28:22 +00:00
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
2022-08-12 07:56:56 +00:00
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
2022-08-12 07:56:56 +00:00
* @return void
*/
protected function schedule(Schedule $schedule)
{
2022-11-19 04:37:18 +00:00
// 清理过期的 Token
2022-11-06 11:28:22 +00:00
$schedule->command('sanctum:prune-expired --hours=24')->daily();
2022-11-19 04:37:18 +00:00
// 扣费
2022-11-19 14:42:47 +00:00
$schedule->job(new HostCost(now()->hour))->hourly()->withoutOverlapping()->onOneServer();
2022-11-19 04:37:18 +00:00
// 获取模块暴露的信息(服务器等)
2022-11-06 11:28:22 +00:00
$schedule->job(new FetchModule())->withoutOverlapping()->everyMinute();
2022-11-19 04:37:18 +00:00
// 推送工单
2022-11-06 11:28:22 +00:00
$schedule->job(new PushWorkOrder())->everyMinute()->onOneServer();
2022-11-19 04:37:18 +00:00
// 自动关闭工单
$schedule->job(new AutoCloseWorkOrder())->everyMinute()->onOneServer();
2022-08-13 08:37:17 +00:00
2022-11-19 04:37:18 +00:00
// 清理任务
2022-09-03 05:22:40 +00:00
$schedule->job(new ClearTasks())->weekly();
2022-11-19 04:37:18 +00:00
// 删除暂停或部署时间超过 3 天以上的主机
2022-09-03 06:01:51 +00:00
$schedule->job(new DeleteHost())->hourly();
2022-09-18 06:28:29 +00:00
2022-11-19 04:37:18 +00:00
// 检查主机是否存在于模块
2022-11-08 09:48:59 +00:00
$schedule->job(new CheckHostIfExistsOnModule())->everyThirtyMinutes()->withoutOverlapping()->onOneServer();
2022-11-08 09:46:00 +00:00
2022-11-19 04:37:18 +00:00
// 检查未充值的订单,并充值
2022-11-04 12:01:27 +00:00
$schedule->job(new CheckAndChargeBalance())->everyFiveMinutes()->onOneServer()->withoutOverlapping();
2022-11-19 04:37:18 +00:00
// 发送模块收益
$schedule->job(new SendModuleEarnings())->dailyAt('20:00');
2022-11-06 11:28:22 +00:00
}
2022-09-21 05:35:09 +00:00
2022-11-06 11:28:22 +00:00
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
2022-10-31 11:50:32 +00:00
2022-11-06 11:28:22 +00:00
require base_path('routes/console.php');
2022-08-12 07:56:56 +00:00
}
}