mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
This commit updates the logger.debug statements in multiple files to log the message 'Exiting node process' instead of 'Exiting node process'. This change improves the logging consistency and ensures that the appropriate log level is used for this message.
82 lines
2.5 KiB
TypeScript
82 lines
2.5 KiB
TypeScript
import Express, {
|
|
ExpressRequest,
|
|
ExpressResponse,
|
|
ExpressRouter,
|
|
} from '../Utils/Express';
|
|
import LocalCache from '../Infrastructure/LocalCache';
|
|
import Response from '../Utils/Response';
|
|
import ServerException from 'Common/Types/Exception/ServerException';
|
|
import logger from '../Utils/Logger';
|
|
import Exception from 'Common/Types/Exception/Exception';
|
|
|
|
export interface StatusAPIOptions {
|
|
readyCheck: () => Promise<void>;
|
|
liveCheck: () => Promise<void>;
|
|
}
|
|
|
|
export default class StatusAPI {
|
|
public static init(options: StatusAPIOptions): ExpressRouter {
|
|
const router: ExpressRouter = Express.getRouter();
|
|
|
|
router.get(
|
|
'/app-name',
|
|
(_req: ExpressRequest, res: ExpressResponse) => {
|
|
res.send({ app: LocalCache.getString('app', 'name') });
|
|
}
|
|
);
|
|
|
|
// General status
|
|
router.get('/status', (req: ExpressRequest, res: ExpressResponse) => {
|
|
Response.sendJsonObjectResponse(req, res, {
|
|
status: 'ok',
|
|
});
|
|
});
|
|
|
|
//Healthy probe
|
|
router.get(
|
|
'/status/ready',
|
|
async (req: ExpressRequest, res: ExpressResponse) => {
|
|
try {
|
|
logger.debug('Ready check');
|
|
await options.readyCheck();
|
|
Response.sendJsonObjectResponse(req, res, {
|
|
status: 'ok',
|
|
});
|
|
} catch (e) {
|
|
Response.sendErrorResponse(
|
|
req,
|
|
res,
|
|
e instanceof Exception
|
|
? e
|
|
: new ServerException('Server is not ready')
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
//Liveness probe
|
|
router.get(
|
|
'/status/live',
|
|
async (req: ExpressRequest, res: ExpressResponse) => {
|
|
try {
|
|
logger.debug('Live check');
|
|
await options.readyCheck();
|
|
Response.sendJsonObjectResponse(req, res, {
|
|
status: 'ok',
|
|
});
|
|
} catch (e) {
|
|
Response.sendErrorResponse(
|
|
req,
|
|
res,
|
|
e instanceof Exception
|
|
? e
|
|
: new ServerException('Server is not ready')
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
return router;
|
|
}
|
|
}
|