Skip to content

Commit

Permalink
wipppp
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed May 13, 2024
1 parent 15edfbf commit b00033d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CountItems/masterProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ const countMaster = new CountMaster({
});

metricServer.onRequest((req, res) => monitoring.metricsHandler(
countMaster.stop.bind(countMaster),
countMaster,
() => process.exit(1),
req,
res,
));

const handleSignal = sig => countMaster.stop(sig, () => process.exit(0));
process.on('SIGINT', handleSignal);
process.on('SIGHUP', handleSignal);
Expand Down
4 changes: 2 additions & 2 deletions utils/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function _writeResponse(res, error) {
* @param {http.ServerResponse} res - http response object

Check failure on line 68 in utils/monitoring.js

View workflow job for this annotation

GitHub Actions / tests

Expected JSDoc for 'req' but found 'res'
* @return {void}
*/
async function metricsHandler(onScraped, req, res) {
async function metricsHandler(countMasterInstance, onScraped, req, res) {
if (req.method !== 'GET' || req.url !== '/metrics') {
return _writeResponse(res, errors.MethodNotAllowed);
}
Expand All @@ -88,7 +88,7 @@ async function metricsHandler(onScraped, req, res) {
return _writeResponse(res, errors.MethodNotAllowed);
} finally {
if (CountMaster.waitingForPromScraping === true) {
onScraped();
countMasterInstance.stop(null, onScraped);
}
}
}
Expand Down

0 comments on commit b00033d

Please sign in to comment.