1
0
mirror of https://gitlab.com/depesz/explain.depesz.com.git synced 2025-07-03 00:58:12 +02:00

Implement /status to show if db is accessible

This commit is contained in:
Hubert depesz Lubaczewski
2018-06-11 20:56:49 +02:00
parent c409a2ad48
commit 00d63257bb
3 changed files with 17 additions and 0 deletions

View File

@ -41,6 +41,9 @@ sub startup {
# route: 'index'
$routes->route( '/' )->to( 'controller#index' )->name( 'new-explain' );
# route: 'status'
$routes->route( '/status' )->to( 'controller#status' )->name( 'status' );
# route: 'new-optimization'
$routes->route( '/new_optimization' )->to( 'controller#new_optimization' )->name( 'new-optimization' );

View File

@ -412,6 +412,15 @@ sub info {
}
sub status {
my $self = shift;
if ($self->database->ping()) {
$self->render('text' => 'OK', status => 200);
} else {
$self->render('text' => 'DB FAILED', status => 500);
}
}
sub help {
# direct to template

View File

@ -223,6 +223,11 @@ sub save_with_random_name {
return @row;
}
sub ping {
my $self = shift;
return $self->dbh->ping();
}
sub get_plan_data {
my $self = shift;
my ( $plan_id ) = @_;