Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add healthcheck for each express instance. #645

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions controllers/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ export function bindRoutes(app) {
});

// Ping-pong to verify the server is working
app.all('/ping', (req, res) => {
res.status(200).send('pong');
app.all('/health', (req, res) => {
res.set('Cache-Control', 'no-store');
res.status(200).send('OK');
});

// Last handler. If request reaches it, means that there is no handler for this request
Expand Down
8 changes: 8 additions & 0 deletions downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ export async function configure(startStamp) {
// Start server and do manual manual url router, express is not needed
const server = http
.createServer(function handleRequest(req, res) {
if (req.url === '/health') {
res.setHeader('Cache-Control', 'no-store');
res.statusCode = 200;
res.end('OK');

return;
}

if (protectedServePattern.test(req.url)) {
return protectedHandler(req, res);
}
Expand Down
8 changes: 8 additions & 0 deletions uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ export function configure(startStamp) {
};

const handleRequest = (req, res) => {
if (req.url === '/health') {
res.setHeader('Cache-Control', 'no-store');
res.statusCode = 200;
res.end('OK');

return;
}

if (req.url !== '/upload' && req.url !== '/uploadava') {
res.statusCode = 403;
res.end();
Expand Down
Loading