mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-28 12:30:42 +02:00
Further work on better logging
This commit is contained in:
parent
595d10349c
commit
2adce55a07
6 changed files with 69 additions and 78 deletions
|
@ -52,7 +52,17 @@ $log->info('server started.');
|
|||
// Handle incoming HTTP requests
|
||||
$http->on('request', function ($request, $response) use ($c, $pool, $log, $rateLimiter) {
|
||||
// Get a PDO connection from the pool
|
||||
$pdo = $pool->get();
|
||||
try {
|
||||
$pdo = $pool->get();
|
||||
if (!$pdo) {
|
||||
throw new PDOException("Failed to retrieve a connection from Swoole PDOPool.");
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$log->alert("Swoole PDO Pool failed: " . $e->getMessage());
|
||||
$response->header('Content-Type', 'application/json');
|
||||
$response->status(500);
|
||||
$response->end(json_encode(['error' => 'Database failure. Please try again later.']));
|
||||
}
|
||||
|
||||
$remoteAddr = $request->server['remote_addr'];
|
||||
if (!isIpWhitelisted($remoteAddr, $pdo)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue