Comments (1)
I actually can't recall why I did it this way, but here's how I implemented this package for our readinessProbe
A health route:
// health routes
Route::get('/health', 'HealthCheckController@index');
A custom HealthCheckController:
<?php
namespace App\Http\Controllers;
use PragmaRX\Health\Http\Controllers\Health;
class HealthCheckController extends Controller {
public function index() {
$services = array_map('strtolower', config('health.resources.enabled'));
foreach($services as $service){
$serviceHealth = app('pragmarx.health')->checkResource($service)->isHealthy();
if (!$serviceHealth) {
return "Service: $service is not healthy";
}
}
return 'Healthy!';
}
}
a PHP file to call call this health check by-passing laravel (this is where I'm not sure why I did it this way)
<?php
// Start output buffering (Capture STDOUT)
ob_start();
// Check that artisan ran through start.sh
//if (!file_exists('/ready')) { exit(1); }
// Check that php-fpm is running as well
$output = shell_exec('ps aux | grep [p]hp-fpm');
if (empty($output)){
echo "Can't find php-fpm, exiting with error";
exit(1);
}
$host = getenv('PLACEHOLDER_API_URL_NO_PROTOCOL');
if (empty($host)){
$host = 'local.api.REMOVED.com';
}
$_SERVER['REQUEST_URI'] = '/v1.0/health';
$_SERVER['HTTP_ACCEPT'] = '*/*';
$_SERVER['HTTP_USER_AGENT'] = 'curl/7.47.0';
$_SERVER['HTTP_CONNECTION'] = 'close';
$_SERVER['HTTP_HOST'] = $host;
// Start output buffering (Capture STDOUT)
ob_start();
require_once 'server.php';
$content = ob_get_contents();
if (strpos($content, 'Healthy!') !== false) {
// Success
exit(0);
} else {
// Failure
echo "Content is not Healthy! val: $content";
exit(1);
}
ob_end_clean();
and lastly the readinessProbe config:
readinessProbe:
exec:
command:
- php
- /var/www/health_check.php
There MIGHT be a reason I decided to do the HTTP request in a "health_check" php file rather than doing it from the readinessProbe, but I couldn't explain why anymore. Sorry, that was a long time ago
from health.
Related Issues (20)
- Enhancement: feature to monitor Health on other managed sites HOT 3
- Broadcasting Failure HOT 1
- Package is ignoring APP_URL HOT 1
- Support phpunit/php-timer 3.0.0 HOT 5
- Failed to send Slack Notification
- Laravel 7 support HOT 2
- SensioLabs - Version HOT 1
- [Latency] Checkers/Ping: implode(): Passing glue string after array is deprecated. Swap the parameters HOT 1
- Type Error issue with latest Laravel 7.x HOT 4
- Latest master commit breaks "runtime" values
- health:panel reporting errors should return exit code > 0 HOT 1
- Update phpunit/php-timer dependency to ^1.0|^2.0|^3.0|^4.0|^5.0 HOT 4
- Broken scheduler config HOT 4
- [Laravel version:8.11.2] DomainException : Invalid value for config('health.resources.enabled'') when trying to publish config and views HOT 3
- Sunsetting SensioLabs Security Checker HOT 4
- Support for health checks to be in NPRE format HOT 1
- Add support for varying degrees of health (OK, WARNING, CRITICAL, UNKNOWN) - NPRE format HOT 1
- Laravel 5.8: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')' HOT 1
- Installing on Larvel 10 fires error Illuminate\Container\Container::bind(): Argument #2 ($concrete) must be of type Closure|string|null HOT 1
- Flutter Integration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from health.