@vtex/api 7.2.1-beta.1 → 7.2.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/service/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
import { MetricsAccumulator } from '../metrics/MetricsAccumulator';
|
|
1
2
|
export declare const startApp: () => Promise<void>;
|
|
2
3
|
export { appPath } from './loaders';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace NodeJS {
|
|
6
|
+
interface Global {
|
|
7
|
+
metrics: MetricsAccumulator;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
package/lib/service/index.js
CHANGED
|
@@ -30,10 +30,13 @@ exports.appPath = exports.startApp = void 0;
|
|
|
30
30
|
const telemetry_1 = require("./telemetry");
|
|
31
31
|
const cluster_1 = __importDefault(require("cluster"));
|
|
32
32
|
const constants_1 = require("../constants");
|
|
33
|
+
const MetricsAccumulator_1 = require("../metrics/MetricsAccumulator");
|
|
33
34
|
const loaders_1 = require("./loaders");
|
|
34
35
|
const logger_1 = require("./logger");
|
|
35
36
|
const startApp = async () => {
|
|
36
37
|
await (0, telemetry_1.initializeTelemetry)();
|
|
38
|
+
// Initialize global.metrics for both master and worker processes
|
|
39
|
+
global.metrics = new MetricsAccumulator_1.MetricsAccumulator();
|
|
37
40
|
const serviceJSON = (0, loaders_1.getServiceJSON)();
|
|
38
41
|
try {
|
|
39
42
|
// if it is a master process then call setting up worker process
|
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import Koa from 'koa';
|
|
2
|
-
import { MetricsAccumulator } from '../../metrics/MetricsAccumulator';
|
|
3
2
|
import { ServiceJSON } from './runtime/typings';
|
|
4
3
|
export declare const startWorker: (serviceJSON: ServiceJSON) => Koa<Koa.DefaultState, Koa.DefaultContext>;
|
|
5
|
-
declare global {
|
|
6
|
-
namespace NodeJS {
|
|
7
|
-
interface Global {
|
|
8
|
-
metrics: MetricsAccumulator;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -11,7 +11,6 @@ const koa_compress_1 = __importDefault(require("koa-compress"));
|
|
|
11
11
|
const koa_router_1 = __importDefault(require("koa-router"));
|
|
12
12
|
const ramda_1 = require("ramda");
|
|
13
13
|
const constants_1 = require("../../constants");
|
|
14
|
-
const MetricsAccumulator_1 = require("../../metrics/MetricsAccumulator");
|
|
15
14
|
const loaders_1 = require("../loaders");
|
|
16
15
|
const console_1 = require("../logger/console");
|
|
17
16
|
const loggerTypes_1 = require("../logger/loggerTypes");
|
|
@@ -198,4 +197,3 @@ const startWorker = (serviceJSON) => {
|
|
|
198
197
|
return app;
|
|
199
198
|
};
|
|
200
199
|
exports.startWorker = startWorker;
|
|
201
|
-
global.metrics = new MetricsAccumulator_1.MetricsAccumulator();
|
|
@@ -23,11 +23,9 @@ const statusTrackHandler = async (ctx) => {
|
|
|
23
23
|
};
|
|
24
24
|
exports.statusTrackHandler = statusTrackHandler;
|
|
25
25
|
const trackStatus = () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
}
|
|
26
|
+
global.metrics.statusTrack().forEach(status => {
|
|
27
|
+
logStatus(status);
|
|
28
|
+
});
|
|
31
29
|
};
|
|
32
30
|
exports.trackStatus = trackStatus;
|
|
33
31
|
const broadcastStatusTrack = () => Object.values(cluster_1.default.workers).forEach(worker => worker === null || worker === void 0 ? void 0 : worker.send(STATUS_TRACK));
|