Phillip/prod perf2 (#15596)
* Add new api call for kubernetes startup probe * add hostname as tag for loggly * Only listen to one change * increase vite min chunk size * respond gracefully to shutdown signal * update server readiness according to mongodb and redis connection * make larger vite chunks * fix lint
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
disableCache,
|
||||
} from '../../middlewares/cache';
|
||||
import SERVER_STATUS from '../../libs/serverStatus';
|
||||
|
||||
const api = {};
|
||||
|
||||
/**
|
||||
* @api {get} /api/v3/ready Get Habitica's Server readiness status
|
||||
* @apiName GetReady
|
||||
* @apiGroup Status
|
||||
*
|
||||
* @apiSuccess {String} data.status 'ready' if everything is ok
|
||||
*
|
||||
* @apiSuccessExample {JSON} Server is Ready
|
||||
* {
|
||||
* 'status': 'ready',
|
||||
* }
|
||||
*/
|
||||
api.getReady = {
|
||||
method: 'GET',
|
||||
url: '/ready',
|
||||
// explicitly disable caching so that the server is always checked
|
||||
middlewares: [disableCache],
|
||||
async handler (req, res) {
|
||||
// This allows kubernetes to determine if the server is ready to receive traffic
|
||||
if (!SERVER_STATUS.MONGODB || !SERVER_STATUS.REDIS || !SERVER_STATUS.EXPRESS) {
|
||||
res.respond(503, {
|
||||
status: 'not ready',
|
||||
});
|
||||
} else {
|
||||
res.respond(200, {
|
||||
status: 'ready',
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default api;
|
||||
Reference in New Issue
Block a user