MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / registerHealthEndpoint

Function registerHealthEndpoint

js/botasaurus-server-js/src/api-config.ts:452–468  ·  view source on GitHub ↗

* Register health endpoint

(app: FastifyInstance)

Source from the content-addressed store, hash-verified

450 * Register health endpoint
451 */
452function registerHealthEndpoint(app: FastifyInstance) {
453 app.get('/health', async (_, reply) => {
454 // Check if worker is shutting down
455 if (ApiConfig.isWorkerNode()) {
456 const executor = getExecutor() as WorkerExecutor;
457 if (executor.isShuttingDown) {
458 return reply.status(503).send({ status: 'shutting_down' });
459 }
460 }
461 try {
462 await db.countAsync({});
463 return { status: 'ok' };
464 } catch (_) {
465 return reply.status(503).send({ status: 'database_unreachable' });
466 }
467 });
468}
469
470export function buildApp(
471 scrapers: any[],

Callers 1

buildAppFunction · 0.85

Calls 3

getExecutorFunction · 0.90
isWorkerNodeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected