From 6268d052ed27ec641262004e46facd60b836b48b Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Thu, 12 Jan 2023 21:36:18 +0300 Subject: [PATCH 1/3] Fixed health status return back after fail --- backend/backend.config.js | 1 + backend/index.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/backend/backend.config.js b/backend/backend.config.js index a3f6ff07..8c02c235 100644 --- a/backend/backend.config.js +++ b/backend/backend.config.js @@ -13,6 +13,7 @@ module.exports = { port: parseInt(process.env.POSTGRES_PORT, 10) || 5432, }, logLevel: process.env.LOG_LEVEL || 'info', // Use 'debug' to see DEBUG level messages + spawnTimeoutMs: parseInt(process.env.SPAWN_TIMEOUT_MS, 10) || 5000, crawlers: [ { name: 'blockListener', diff --git a/backend/index.js b/backend/index.js index b5b86e12..28e850c8 100644 --- a/backend/index.js +++ b/backend/index.js @@ -27,6 +27,7 @@ const runCrawler = async ({ crawler, name }) => { child.on('exit', (exitCode, signal) => { logger.warn(`Crawler ${crawler} exit with code: ${exitCode} and signal: ${signal}`); status.set(name, `exit code ${exitCode}, signal ${signal}`); + setTimeout(() => runCrawler({ crawler, name }), config.spawnTimeoutMs); }); child.on('uncaughtException', (error) => { logger.warn(`Crawler ${crawler} exit with uncaughtException: ${error}`); @@ -40,6 +41,10 @@ const runCrawler = async ({ crawler, name }) => { logger.warn(`Crawler ${crawler} exit SIGUSR2`); status.set(name, 'exit SIGUSR2'); }); + child.on('spawn', () => { + logger.info('Process spawned'); + status.set(name, 'healthy'); + }); }; const runCrawlers = async () => { From 586c79e95cd273394916f0a5284445fc33e36ad7 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Thu, 12 Jan 2023 21:51:54 +0300 Subject: [PATCH 2/3] Use app status from constant --- backend/index.js | 4 ++-- backend/lib/status.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/index.js b/backend/index.js index 28e850c8..71ee76a6 100644 --- a/backend/index.js +++ b/backend/index.js @@ -6,7 +6,7 @@ const { spawn } = require('child_process'); const { StatusCodes } = require('http-status-codes'); const { wait, getEnabledCrawlerNames, getEnabledCrawlers } = require('./lib/utils'); const config = require('./backend.config'); -const Status = require('./lib/status'); +const { Status, statuses: appStatuses } = require('./lib/status'); const app = express(); const logger = pino(); @@ -43,7 +43,7 @@ const runCrawler = async ({ crawler, name }) => { }); child.on('spawn', () => { logger.info('Process spawned'); - status.set(name, 'healthy'); + status.set(name, appStatuses.HEALTHY); }); }; diff --git a/backend/lib/status.js b/backend/lib/status.js index d4fa36f5..a59e6564 100644 --- a/backend/lib/status.js +++ b/backend/lib/status.js @@ -26,4 +26,7 @@ class Status { } } -module.exports = Status; +module.exports = { + statuses, + Status, +}; From 7903e91eb4028214243060ef745ef94f9a9bd97c Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Tue, 24 Jan 2023 18:27:14 +0300 Subject: [PATCH 3/3] Release v0.25.0 --- CHANGELOG.md | 3 +++ api/package.json | 2 +- backend/package.json | 2 +- frontend/package.json | 2 +- package.json | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72d3a118..9818985d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## vNext - ... +## v0.25.0 +- [BE] Fix crawlers status restore after fail + ## v0.24.3 - [BE] Add missing `next` functions to prevent Stats API crash diff --git a/api/package.json b/api/package.json index 80facafb..ec3a103d 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "0.24.3", + "version": "0.25.0", "description": "PolkaStats API", "author": "Mario Pino Uceda", "license": "Apache-2.0", diff --git a/backend/package.json b/backend/package.json index 3f095c88..ac294078 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "version": "0.24.3", + "version": "0.25.0", "description": "PolkaStats NG Backend", "author": "Mario Pino Uceda", "license": "Apache-2.0", diff --git a/frontend/package.json b/frontend/package.json index 61a6f509..80166bd9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "0.24.3", + "version": "0.25.0", "description": "PolkaStats NG frontend", "author": "Mario Pino Uceda", "license": "Apache-2.0", diff --git a/package.json b/package.json index dd90ea6a..270fc671 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "cerestats", - "version": "0.24.3", + "version": "0.25.0", "description": "Cere Stats mono repo", "repository": { "type": "git",