Skip to content

Commit

Permalink
Merge branch 'main' into alain_translations
Browse files Browse the repository at this point in the history
  • Loading branch information
alainvd committed Apr 17, 2024
2 parents 865afef + ddd98d7 commit 1c12efa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/Console/Commands/Heartbeat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class Heartbeat extends Command
{

protected $signature = 'heartbeat';

protected $description = 'Check if the database is up by querying the users table.';

public function handle()
{
try {
// Attempt to query the users table
DB::table('statements')->select(DB::raw(1))->take(1)->get();

// If the query is successful, database is up
$this->info('Database is up.');

} catch (\Exception $e) {
// If an exception occurs, database is down
$this->error('Database is down: ' . $e->getMessage());
}
}
}

0 comments on commit 1c12efa

Please sign in to comment.