@@ -7,6 +7,7 @@ use App\Repositories\KvpRepository;
|
|||||||
use App\Repositories\NewsRepository;
|
use App\Repositories\NewsRepository;
|
||||||
use App\Repositories\PirepRepository;
|
use App\Repositories\PirepRepository;
|
||||||
use App\Repositories\UserRepository;
|
use App\Repositories\UserRepository;
|
||||||
|
use App\Services\CronService;
|
||||||
use App\Services\NewsService;
|
use App\Services\NewsService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -15,6 +16,7 @@ use Laracasts\Flash\Flash;
|
|||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
|
private $cronSvc;
|
||||||
private $kvpRepo;
|
private $kvpRepo;
|
||||||
private $newsRepo;
|
private $newsRepo;
|
||||||
private $newsSvc;
|
private $newsSvc;
|
||||||
@@ -24,6 +26,7 @@ class DashboardController extends Controller
|
|||||||
/**
|
/**
|
||||||
* DashboardController constructor.
|
* DashboardController constructor.
|
||||||
*
|
*
|
||||||
|
* @param CronService $cronSvc
|
||||||
* @param KvpRepository $kvpRepo
|
* @param KvpRepository $kvpRepo
|
||||||
* @param NewsRepository $newsRepo
|
* @param NewsRepository $newsRepo
|
||||||
* @param NewsService $newsSvc
|
* @param NewsService $newsSvc
|
||||||
@@ -31,12 +34,14 @@ class DashboardController extends Controller
|
|||||||
* @param UserRepository $userRepo
|
* @param UserRepository $userRepo
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
CronService $cronSvc,
|
||||||
KvpRepository $kvpRepo,
|
KvpRepository $kvpRepo,
|
||||||
NewsRepository $newsRepo,
|
NewsRepository $newsRepo,
|
||||||
NewsService $newsSvc,
|
NewsService $newsSvc,
|
||||||
PirepRepository $pirepRepo,
|
PirepRepository $pirepRepo,
|
||||||
UserRepository $userRepo
|
UserRepository $userRepo
|
||||||
) {
|
) {
|
||||||
|
$this->cronSvc = $cronSvc;
|
||||||
$this->kvpRepo = $kvpRepo;
|
$this->kvpRepo = $kvpRepo;
|
||||||
$this->newsRepo = $newsRepo;
|
$this->newsRepo = $newsRepo;
|
||||||
$this->newsSvc = $newsSvc;
|
$this->newsSvc = $newsSvc;
|
||||||
@@ -79,10 +84,10 @@ class DashboardController extends Controller
|
|||||||
$this->checkNewVersion();
|
$this->checkNewVersion();
|
||||||
|
|
||||||
return view('admin.dashboard.index', [
|
return view('admin.dashboard.index', [
|
||||||
'news' => $this->newsRepo->getLatest(),
|
'news' => $this->newsRepo->getLatest(),
|
||||||
// 'installer_enabled' => $installerEnabled,
|
'pending_pireps' => $this->pirepRepo->getPendingCount(),
|
||||||
'pending_pireps' => $this->pirepRepo->getPendingCount(),
|
'pending_users' => $this->userRepo->getPendingCount(),
|
||||||
'pending_users' => $this->userRepo->getPendingCount(),
|
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,8 @@ class MaintenanceController extends Controller
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// Generate the cron path. Replace php-fpm with just php
|
|
||||||
$cron_path = [
|
|
||||||
'* * * * *',
|
|
||||||
$this->cronSvc->getCronPath(),
|
|
||||||
'>> /dev/null 2>&1',
|
|
||||||
];
|
|
||||||
|
|
||||||
return view('admin.maintenance.index', [
|
return view('admin.maintenance.index', [
|
||||||
'cron_path' => implode(' ', $cron_path),
|
'cron_path' => $this->cronSvc->getCronExecString(),
|
||||||
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
|
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
// Only load the IDE helper if it's included and enabled
|
// Only load the IDE helper if it's included and enabled
|
||||||
if (config('app.debug_toolbar') === true) {
|
if (config('app.debug') === true) {
|
||||||
/* @noinspection NestedPositiveIfStatementsInspection */
|
/* @noinspection NestedPositiveIfStatementsInspection */
|
||||||
/* @noinspection PhpFullyQualifiedNameUsageInspection */
|
/* @noinspection PhpFullyQualifiedNameUsageInspection */
|
||||||
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
|
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use DateTime;
|
|||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
|
|
||||||
class CronService extends Service
|
class CronService extends Service
|
||||||
{
|
{
|
||||||
@@ -26,16 +27,33 @@ class CronService extends Service
|
|||||||
*/
|
*/
|
||||||
public function getCronPath(): string
|
public function getCronPath(): string
|
||||||
{
|
{
|
||||||
|
$finder = new PhpExecutableFinder();
|
||||||
|
$php_path = $finder->find(false);
|
||||||
|
|
||||||
$path = [
|
$path = [
|
||||||
'cd '.base_path(),
|
'cd '.base_path(),
|
||||||
'&&',
|
'&&',
|
||||||
str_replace('-fpm', '', PHP_BINARY),
|
str_replace('-fpm', '', $php_path),
|
||||||
'artisan schedule:run',
|
'artisan schedule:run',
|
||||||
];
|
];
|
||||||
|
|
||||||
return implode(' ', $path);
|
return implode(' ', $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an example cron command that runs every minute
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCronExecString(): string
|
||||||
|
{
|
||||||
|
return implode(' ', [
|
||||||
|
'* * * * *',
|
||||||
|
$this->getCronPath(),
|
||||||
|
'>> /dev/null 2>&1',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the last time the cron was run in the kvp repo
|
* Update the last time the cron was run in the kvp repo
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
@section('title', 'Dashboard')
|
@section('title', 'Dashboard')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
@if($cron_problem_exists)
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
There was a problem running the cron; make sure it's setup and check logs at
|
||||||
|
<span class="text-monospace bg-gradient-dark">storage/logs/cron.log</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
|
|||||||
Reference in New Issue
Block a user