mirror of
https://github.com/v2board/v2board.git
synced 2024-11-14 07:29:13 +08:00
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Models\ServerShadowsocks;
|
|
use App\Models\ServerTrojan;
|
|
use App\Services\ServerService;
|
|
use App\Utils\CacheKey;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\ServerGroup;
|
|
use App\Models\ServerV2ray;
|
|
use App\Models\Plan;
|
|
use App\Models\User;
|
|
use App\Models\Ticket;
|
|
use App\Models\Order;
|
|
use App\Models\StatOrder;
|
|
use App\Models\StatServer;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Laravel\Horizon\Contracts\MasterSupervisorRepository;
|
|
|
|
class SystemController extends Controller
|
|
{
|
|
public function getStatus()
|
|
{
|
|
return response([
|
|
'data' => [
|
|
'schedule' => $this->getScheduleStatus(),
|
|
'horizon' => $this->getHorizonStatus()
|
|
]
|
|
]);
|
|
}
|
|
|
|
protected function getScheduleStatus():bool
|
|
{
|
|
return (time() - 120) < Cache::get(CacheKey::get('SCHEDULE_LAST_CHECK_AT', null));
|
|
}
|
|
|
|
protected function getHorizonStatus():bool
|
|
{
|
|
if (! $masters = app(MasterSupervisorRepository::class)->all()) {
|
|
return false;
|
|
}
|
|
|
|
return collect($masters)->contains(function ($master) {
|
|
return $master->status === 'paused';
|
|
}) ? false : true;
|
|
}
|
|
}
|
|
|