重命名 任务

This commit is contained in:
iVampireSP.com 2022-12-28 21:17:54 +08:00
parent 86d3a2d361
commit 770778c78c
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
17 changed files with 40 additions and 40 deletions

View File

@ -48,7 +48,7 @@ public function handle()
$this->info('封禁: ' . $user->name); $this->info('封禁: ' . $user->name);
$this->confirm('确定要继续吗?如果继续,将会暂停所有的 Host,并且吊销所有 Token。'); $this->confirm('确定要继续吗?如果继续,将会暂停所有的主机,并且吊销所有 Token。');
$user->banned_at = now(); $user->banned_at = now();
$user->banned_reason = $reason; $user->banned_reason = $reason;

View File

@ -19,7 +19,7 @@ class SuspendUserAllHosts extends Command
* *
* @var string * @var string
*/ */
protected $description = '暂停用户的所有 Host'; protected $description = '暂停用户的所有主机。';
/** /**
* Create a new command instance. * Create a new command instance.
@ -47,6 +47,6 @@ public function handle()
'suspended_at' => now() 'suspended_at' => now()
]); ]);
$this->info('暂停用户的所有 Host 成功。'); $this->info('暂停用户的所有主机成功。');
} }
} }

View File

@ -2,15 +2,15 @@
namespace App\Console; namespace App\Console;
use App\Jobs\AutoCloseWorkOrder; use App\Jobs\AutoCloseWorkOrderJob;
use App\Jobs\CheckAndChargeBalance; use App\Jobs\CheckAndChargeBalanceJob;
use App\Jobs\CheckHostIfExistsOnModule; use App\Jobs\CheckHostIfExistsOnModuleJob;
use App\Jobs\ClearTasks; use App\Jobs\ClearTasksJob;
use App\Jobs\DeleteHost; use App\Jobs\DeleteHostJob;
use App\Jobs\HostCost; use App\Jobs\HostCostJob;
use App\Jobs\Module\FetchModule; use App\Jobs\Module\FetchModuleJob;
use App\Jobs\Module\PushWorkOrder; use App\Jobs\Module\PushWorkOrderJob;
use App\Jobs\SendModuleEarnings; use App\Jobs\SendModuleEarningsJob;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@ -29,30 +29,30 @@ protected function schedule(Schedule $schedule)
$schedule->command('sanctum:prune-expired --hours=24')->daily(); $schedule->command('sanctum:prune-expired --hours=24')->daily();
// 扣费 // 扣费
$schedule->job(new HostCost(now()->minute))->everyMinute()->withoutOverlapping()->onOneServer(); $schedule->job(new HostCostJob(now()->minute))->everyMinute()->withoutOverlapping()->onOneServer();
// 获取模块暴露的信息(服务器等) // 获取模块暴露的信息(服务器等)
$schedule->job(new FetchModule())->withoutOverlapping()->everyMinute(); $schedule->job(new FetchModuleJob())->withoutOverlapping()->everyMinute();
// 推送工单 // 推送工单
$schedule->job(new PushWorkOrder())->everyMinute()->onOneServer(); $schedule->job(new PushWorkOrderJob())->everyMinute()->onOneServer();
// 自动关闭工单 // 自动关闭工单
$schedule->job(new AutoCloseWorkOrder())->everyMinute()->onOneServer(); $schedule->job(new AutoCloseWorkOrderJob())->everyMinute()->onOneServer();
// 清理任务 // 清理任务
$schedule->job(new ClearTasks())->weekly(); $schedule->job(new ClearTasksJob())->weekly();
// 删除暂停或部署时间超过 3 天以上的主机 // 删除暂停或部署时间超过 3 天以上的主机
$schedule->job(new DeleteHost())->hourly(); $schedule->job(new DeleteHostJob())->hourly();
// 检查主机是否存在于模块 // 检查主机是否存在于模块
$schedule->job(new CheckHostIfExistsOnModule())->everyThirtyMinutes()->withoutOverlapping()->onOneServer(); $schedule->job(new CheckHostIfExistsOnModuleJob())->everyThirtyMinutes()->withoutOverlapping()->onOneServer();
// 检查未充值的订单,并充值 // 检查未充值的订单,并充值
$schedule->job(new CheckAndChargeBalance())->everyFiveMinutes()->onOneServer()->withoutOverlapping(); $schedule->job(new CheckAndChargeBalanceJob())->everyFiveMinutes()->onOneServer()->withoutOverlapping();
// 发送模块收益 // 发送模块收益
$schedule->job(new SendModuleEarnings())->dailyAt('20:00'); $schedule->job(new SendModuleEarningsJob())->dailyAt('20:00');
} }

View File

@ -60,7 +60,7 @@ public function destroy(HostRequest $request, Host $host): JsonResponse
$host->cost(); $host->cost();
} }
dispatch(new \App\Jobs\Module\Host($host, 'delete')); dispatch(new \App\Jobs\Module\HostJob($host, 'delete'));
return $this->deleted($host); return $this->deleted($host);
} }

View File

@ -128,7 +128,7 @@ public function update(Request $request, Host $host): JsonResponse
*/ */
public function destroy($host): JsonResponse public function destroy($host): JsonResponse
{ {
// if host not instance of Host // if host not instance of HostJob
if (!$host instanceof Host) { if (!$host instanceof Host) {
$host = Host::findOrFail($host); $host = Host::findOrFail($host);
} }

View File

@ -4,7 +4,7 @@
use App\Models\WorkOrder\WorkOrder; use App\Models\WorkOrder\WorkOrder;
class AutoCloseWorkOrder extends Job class AutoCloseWorkOrderJob extends Job
{ {
/** /**
* Create a new job instance. * Create a new job instance.

View File

@ -8,7 +8,7 @@
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Yansongda\LaravelPay\Facades\Pay; use Yansongda\LaravelPay\Facades\Pay;
class CheckAndChargeBalance extends Job class CheckAndChargeBalanceJob extends Job
{ {
/** /**
* Create a new job instance. * Create a new job instance.

View File

@ -10,7 +10,7 @@
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CheckHostIfExistsOnModule implements ShouldQueue class CheckHostIfExistsOnModuleJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
@ -44,7 +44,7 @@ public function handle(): void
if ($response->status() === 404) { if ($response->status() === 404) {
Log::warning($host->module->name . ' ' . $host->name . ' ' . $host->id . ' 不存在,删除。'); Log::warning($host->module->name . ' ' . $host->name . ' ' . $host->id . ' 不存在,删除。');
dispatch(new Module\Host($host, 'delete')); dispatch(new Module\HostJob($host, 'delete'));
} }
} }
}); });

View File

@ -10,7 +10,7 @@
// use Illuminate\Contracts\Queue\ShouldBeUnique; // use Illuminate\Contracts\Queue\ShouldBeUnique;
class ClearTasks implements ShouldQueue class ClearTasksJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;

View File

@ -10,7 +10,7 @@
// use Illuminate\Contracts\Queue\ShouldBeUnique; // use Illuminate\Contracts\Queue\ShouldBeUnique;
class DeleteHost implements ShouldQueue class DeleteHostJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;
@ -34,14 +34,14 @@ public function handle(): void
// 查找暂停时间超过 3 天的 host // 查找暂停时间超过 3 天的 host
Host::where('status', 'suspended')->where('suspended_at', '<', now()->subDays(3))->chunk(100, function ($hosts) { Host::where('status', 'suspended')->where('suspended_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
foreach ($hosts as $host) { foreach ($hosts as $host) {
dispatch(new Module\Host($host, 'delete')); dispatch(new Module\HostJob($host, 'delete'));
} }
}); });
// 查找部署时间超过3天以上的 host // 查找部署时间超过3天以上的 host
Host::where('status', 'pending')->where('created_at', '<', now()->subDays(3))->chunk(100, function ($hosts) { Host::where('status', 'pending')->where('created_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
foreach ($hosts as $host) { foreach ($hosts as $host) {
dispatch(new Module\Host($host, 'delete')); dispatch(new Module\HostJob($host, 'delete'));
} }
}); });
} }

View File

@ -9,7 +9,7 @@
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
class HostCost implements ShouldQueue class HostCostJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels, Lock; use InteractsWithQueue, Queueable, SerializesModels, Lock;
@ -47,7 +47,7 @@ public function handle(): void
} }
}); });
// Host::whereIn('status', ['running', 'stopped'])->with('user')->chunk(1000, function ($hosts) { // HostJob::whereIn('status', ['running', 'stopped'])->with('user')->chunk(1000, function ($hosts) {
// foreach ($hosts as $host) { // foreach ($hosts as $host) {
// $host->cost(); // $host->cost();
// } // }

View File

@ -12,7 +12,7 @@
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class FetchModule implements ShouldQueue class FetchModuleJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;

View File

@ -10,7 +10,7 @@
// use Illuminate\Contracts\Queue\ShouldBeUnique; // use Illuminate\Contracts\Queue\ShouldBeUnique;
class Host implements ShouldQueue class HostJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;

View File

@ -10,7 +10,7 @@
// use Illuminate\Contracts\Queue\ShouldBeUnique; // use Illuminate\Contracts\Queue\ShouldBeUnique;
class PushHost implements ShouldQueue class PushHostJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;

View File

@ -12,7 +12,7 @@
// use Illuminate\Contracts\Queue\ShouldBeUnique; // use Illuminate\Contracts\Queue\ShouldBeUnique;
class PushWorkOrder implements ShouldQueue class PushWorkOrderJob implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;

View File

@ -5,7 +5,7 @@
use App\Models\Module; use App\Models\Module;
use App\Notifications\ModuleEarnings; use App\Notifications\ModuleEarnings;
class SendModuleEarnings extends Job class SendModuleEarningsJob extends Job
{ {
/** /**
* Create a new job instance. * Create a new job instance.

View File

@ -137,7 +137,7 @@ protected static function boot()
// when Updated // when Updated
static::updated(function ($model) { static::updated(function ($model) {
dispatch(new \App\Jobs\Module\Host($model, 'patch')); dispatch(new \App\Jobs\Module\HostJob($model, 'patch'));
Cache::forget('user_hosts_' . $model->user_id); Cache::forget('user_hosts_' . $model->user_id);
Cache::forget('user_tasks_' . $model->user_id); Cache::forget('user_tasks_' . $model->user_id);
@ -213,7 +213,7 @@ public function safeDelete(): bool
} }
} }
dispatch(new \App\Jobs\Module\Host($this, 'delete')); dispatch(new \App\Jobs\Module\HostJob($this, 'delete'));
return true; return true;
} }