Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Adds health check endpoint #165

Draft
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Draft
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
15 changes: 15 additions & 0 deletions src/Contracts/HealthCheckController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Laravel\Vapor\Contracts;

use Illuminate\Http\Request;

interface HealthCheckController
{
/**
* Respond to a health check request.
*
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request);
}
7 changes: 7 additions & 0 deletions src/DefinesRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@ public function ensureRoutesAreDefined()
Contracts\SignedStorageUrlController::class.'@store'
)->middleware(config('vapor.middleware', 'web'));
}

if (config('vapor.health_check', true)) {
Route::get(
'/vapor/health-check',
Contracts\HealthCheckController::class
)->middleware(config('vapor.middleware', 'web'));
}
}
}
20 changes: 20 additions & 0 deletions src/Http/Controllers/HealthCheckController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Laravel\Vapor\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Laravel\Vapor\Contracts\HealthCheckController as HealthCheckControllerContract;

class HealthCheckController extends Controller implements HealthCheckControllerContract
{
/**
* Respond to a health check request.
*
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
return response('OK');
}
}
6 changes: 6 additions & 0 deletions src/VaporServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Laravel\Vapor\Console\Commands\VaporHealthCheckCommand;
use Laravel\Vapor\Console\Commands\VaporQueueListFailedCommand;
use Laravel\Vapor\Console\Commands\VaporWorkCommand;
use Laravel\Vapor\Http\Controllers\HealthCheckController;
use Laravel\Vapor\Http\Controllers\SignedStorageUrlController;
use Laravel\Vapor\Http\Middleware\ServeStaticAssets;
use Laravel\Vapor\Queue\VaporConnector;
Expand Down Expand Up @@ -70,6 +71,11 @@ public function register()
SignedStorageUrlController::class
);

$this->app->singleton(
Contracts\HealthCheckController::class,
HealthCheckController::class
);

$this->configure();
$this->offerPublishing();
$this->ensureAssetPathsAreConfigured();
Expand Down