Cron monitoring
This commit is contained in:
@@ -25,15 +25,32 @@ class Kernel extends ConsoleKernel
|
|||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
$schedule->command('scrape:mihaaru')->everyFiveMinutes();
|
$schedule->command('scrape:mihaaru')->everyFiveMinutes()
|
||||||
$schedule->command('scrape:sun')->everyFiveMinutes();
|
->pingOnSuccess("/api/ping/mihaaru");
|
||||||
$schedule->command('scrape:avas')->everyFiveMinutes();
|
|
||||||
$schedule->command('scrape:dhuvas')->everyFiveMinutes();
|
$schedule->command('scrape:sun')->everyFiveMinutes()
|
||||||
$schedule->command('scrape:thiladhun')->everyFiveMinutes();
|
->pingOnSuccess("/api/ping/sun");
|
||||||
$schedule->command('scrape:thepress')->everyFiveMinutes();
|
|
||||||
$schedule->command('scrape:addulive')->everyFiveMinutes();
|
$schedule->command('scrape:avas')->everyFiveMinutes()
|
||||||
$schedule->command('scrape:voice')->everyFiveMinutes();
|
->pingOnSuccess("/api/ping/avas");
|
||||||
$schedule->command('scrape:dhen')->everyFiveMinutes();
|
|
||||||
|
$schedule->command('scrape:dhuvas')->everyFiveMinutes()
|
||||||
|
->pingOnSuccess("/api/ping/dhuvas");
|
||||||
|
|
||||||
|
$schedule->command('scrape:thiladhun')->everyFiveMinutes()
|
||||||
|
->pingOnSuccess("/api/ping/thiladhun");
|
||||||
|
|
||||||
|
$schedule->command('scrape:thepress')->everyFiveMinutes()
|
||||||
|
->pingOnSuccess("/api/ping/thepress");
|
||||||
|
|
||||||
|
$schedule->command('scrape:addulive')->everyFiveMinutes()
|
||||||
|
->pingOnSuccess("/api/ping/addulive");
|
||||||
|
|
||||||
|
$schedule->command('scrape:voice')->everyFiveMinutes()
|
||||||
|
->pingOnSuccess("/api/ping/voice");
|
||||||
|
|
||||||
|
$schedule->command('scrape:dhen')->everyFiveMinutes()
|
||||||
|
->pingOnSuccess("/api/ping/dhen");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
28
app/Http/Controllers/API/MonitorAPIController.php
Normal file
28
app/Http/Controllers/API/MonitorAPIController.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Task;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
class MonitorAPIController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function __invoke($source)
|
||||||
|
{
|
||||||
|
Task::updateOrCreate(["name" => $source], [
|
||||||
|
"name" => $source,
|
||||||
|
"cron" => "Every 5 Mins",
|
||||||
|
"last_ping_at" => Carbon::now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
return 'Success';
|
||||||
|
}
|
||||||
|
}
|
20
app/Http/Controllers/Admin/MonitorController.php
Normal file
20
app/Http/Controllers/Admin/MonitorController.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
class MonitorController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request)
|
||||||
|
{
|
||||||
|
return view('admin.monitor');
|
||||||
|
}
|
||||||
|
}
|
11
app/Models/Task.php
Normal file
11
app/Models/Task.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Task extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
34
database/migrations/2020_09_17_145238_create_tasks_table.php
Normal file
34
database/migrations/2020_09_17_145238_create_tasks_table.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateTasksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('tasks', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('cron');
|
||||||
|
$table->dateTime('last_ping_at');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tasks');
|
||||||
|
}
|
||||||
|
}
|
9
resources/views/admin/monitor.blade.php
Normal file
9
resources/views/admin/monitor.blade.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||||
|
{{ __('Monitor') }}
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
|
||||||
|
</x-app-layout>
|
@@ -22,6 +22,12 @@
|
|||||||
{{ __('Analytics') }}
|
{{ __('Analytics') }}
|
||||||
</x-jet-nav-link>
|
</x-jet-nav-link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
|
||||||
|
<x-jet-nav-link href="/dashboard/monitor" :active="request()->routeIs('dashboard.monitor')">
|
||||||
|
{{ __('Monitor') }}
|
||||||
|
</x-jet-nav-link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Settings Dropdown -->
|
<!-- Settings Dropdown -->
|
||||||
|
@@ -29,6 +29,7 @@ Route::get('sources', [SourcesAPIController::class, 'index'])->name('api.sources
|
|||||||
Route::get('source/{source:slug}',[SourcesAPIController::class, 'show'])->name('api.sources.show');
|
Route::get('source/{source:slug}',[SourcesAPIController::class, 'show'])->name('api.sources.show');
|
||||||
|
|
||||||
Route::get('article/{article:id}', [ArticlesAPIController::class, 'show'])->name('api.article.show');
|
Route::get('article/{article:id}', [ArticlesAPIController::class, 'show'])->name('api.article.show');
|
||||||
|
|
||||||
Route::post('newsletter/subscribe', [NewsLetterAPIController::class, 'store'])->name('api.newsletter.store');
|
Route::post('newsletter/subscribe', [NewsLetterAPIController::class, 'store'])->name('api.newsletter.store');
|
||||||
|
|
||||||
|
Route::get('/ping/{source}', \API\MonitorAPIController::class);
|
||||||
|
|
||||||
|
@@ -59,8 +59,8 @@ Route::middleware(['auth:sanctum', 'verified'])->prefix('dashboard')->namespace(
|
|||||||
]);
|
]);
|
||||||
})->name('dashboard.index');
|
})->name('dashboard.index');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/analytics', AnalyticsController::class)->name('dashboard.analytics');
|
Route::get('/analytics', AnalyticsController::class)->name('dashboard.analytics');
|
||||||
|
Route::get('/monitor', MonitorController::class)->name('dashboard.monitor');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user