mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-22 21:26:04 +00:00
mon: add alternative to /healthcheck
Some monitoring services want a system to look like it's failing hard instead of a system being able to report that it's failing successfully. This commit adds an alternative to healthcheck that throws 500 when any service is failing, as though reporting such depended on the services working, to appease these monitoring services and their semantically incorrect nature of operation. This commit message sets the precedent for "mon:" as a conventional commit style prefix for changes related to system health and monitoring.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2025-present Puter Technologies Inc.
|
||||
*
|
||||
* This file is part of Puter.
|
||||
*
|
||||
* Puter is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
"use strict"
|
||||
const express = require('express');
|
||||
const router = new express.Router();
|
||||
|
||||
// This endpoint is identical to /healthcheck except it reports status 500 when
|
||||
// any service is failing, as though reporting such depended on the services
|
||||
// working.
|
||||
router.get('/healthcheck-abusing-http-status-codes', async (req, res) => {
|
||||
const svc_serverHealth = req.services.get('server-health');
|
||||
|
||||
const status = await svc_serverHealth.get_status();
|
||||
res.status(status.ok ? 200 : 500).json(status);
|
||||
})
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user