Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ BLOG_USES_SLUG=null

SENTRY_LARAVEL_DSN=null
SENTRY_TRACES_SAMPLE_RATE=0

OH_DEAR_API_TOKEN=
OH_DEAR_SITE_ID=
OH_DEAR_HEALTH_CHECK_SECRET=
2 changes: 2 additions & 0 deletions app/Console/Commands/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function handle()
{
$this->info('Migrating...');
$this->call('migrate --force');
$this->info('Sync schedule monitor...');
$this->call('schedule-monitor:sync');
return Command::SUCCESS;
}
}
9 changes: 8 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Spatie\Health\Commands\RunHealthChecksCommand;
use Spatie\Health\Commands\ScheduleCheckHeartbeatCommand;
use Spatie\ScheduleMonitor\Models\MonitoredScheduledTaskLogItem;

class Kernel extends ConsoleKernel
{
Expand All @@ -15,7 +18,11 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
// Often commands
$schedule->command(RunHealthChecksCommand::class)->everyMinute();
$schedule->command(ScheduleCheckHeartbeatCommand::class)->everyMinute();
// Daily commands
$schedule->command('model:prune', ['--model' => MonitoredScheduledTaskLogItem::class])->daily();
}

/**
Expand Down
49 changes: 49 additions & 0 deletions app/Providers/HealthCheckServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Spatie\CpuLoadHealthCheck\CpuLoadCheck;
use Spatie\Health\Checks\Checks\DatabaseCheck;
use Spatie\Health\Checks\Checks\DebugModeCheck;
use Spatie\Health\Checks\Checks\EnvironmentCheck;
use Spatie\Health\Checks\Checks\ScheduleCheck;
use Spatie\Health\Checks\Checks\UsedDiskSpaceCheck;
use Spatie\Health\Facades\Health;

class HealthCheckServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}

/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
// If staging is in app url and in env set expect env to staging
$env = 'production';
if (config('app.env') == 'staging' and str_contains(config('app.url'), 'staging')) {
$env = 'staging';
}
Health::checks([
UsedDiskSpaceCheck::new(),
DatabaseCheck::new(),
CpuLoadCheck::new()
->failWhenLoadIsHigherInTheLast5Minutes(2.0)
->failWhenLoadIsHigherInTheLast15Minutes(1.5),
DebugModeCheck::new(),
EnvironmentCheck::new()->expectEnvironment($env),
ScheduleCheck::new(),
]);
}
}
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
"mtownsend/read-time": "^2.0",
"romanzipp/laravel-seo": "^2.4",
"sentry/sentry-laravel": "^3.1",
"spatie/cpu-load-health-check": "^1.0",
"spatie/laravel-health": "^1.22",
"spatie/laravel-honeypot": "^4.1",
"spatie/laravel-markdown": "^2.2",
"spatie/laravel-permission": "^5.5",
"spatie/laravel-schedule-monitor": "^3.2",
"spatie/laravel-tags": "^4.3"
},
"require-dev": {
Expand Down
Loading