kuzzle 2.45.0 → 2.46.0
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.
|
@@ -133,6 +133,7 @@ export declare class Backend {
|
|
|
133
133
|
*
|
|
134
134
|
*/
|
|
135
135
|
_support: JSONObject;
|
|
136
|
+
private readonly nodeId;
|
|
136
137
|
/**
|
|
137
138
|
* Instantiates a new Kuzzle application
|
|
138
139
|
*
|
|
@@ -170,10 +171,6 @@ export declare class Backend {
|
|
|
170
171
|
* EmbeddedSDK instance
|
|
171
172
|
*/
|
|
172
173
|
get sdk(): EmbeddedSDK;
|
|
173
|
-
/**
|
|
174
|
-
* Cluster node ID
|
|
175
|
-
*/
|
|
176
|
-
get nodeId(): string;
|
|
177
174
|
private get _instanceProxy();
|
|
178
175
|
get started(): boolean;
|
|
179
176
|
protected set started(started: boolean);
|
|
@@ -51,7 +51,9 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
51
51
|
const kuzzle_1 = __importDefault(require("../../kuzzle"));
|
|
52
52
|
const embeddedSdk_1 = require("../shared/sdk/embeddedSdk");
|
|
53
53
|
const kerror = __importStar(require("../../kerror"));
|
|
54
|
-
const index_1 = require("
|
|
54
|
+
const index_1 = require("../../../index");
|
|
55
|
+
const index_2 = require("./index");
|
|
56
|
+
const Logger_1 = require("../../kuzzle/Logger");
|
|
55
57
|
const assertionError = kerror.wrap("plugin", "assert");
|
|
56
58
|
const runtimeError = kerror.wrap("plugin", "runtime");
|
|
57
59
|
let _app = null;
|
|
@@ -115,12 +117,21 @@ class Backend {
|
|
|
115
117
|
throw assertionError.get("invalid_application_name", name);
|
|
116
118
|
}
|
|
117
119
|
this._name = name;
|
|
120
|
+
this.nodeId = index_1.NameGenerator.generateRandomName({ prefix: "knode" });
|
|
118
121
|
Reflect.defineProperty(this, "_kuzzle", {
|
|
119
122
|
writable: true,
|
|
120
123
|
});
|
|
121
124
|
Reflect.defineProperty(this, "_sdk", {
|
|
122
125
|
writable: true,
|
|
123
126
|
});
|
|
127
|
+
Reflect.defineProperty(global, "nodeId", {
|
|
128
|
+
get: () => {
|
|
129
|
+
return this.nodeId;
|
|
130
|
+
},
|
|
131
|
+
set: () => {
|
|
132
|
+
throw new Error("nodeId is read-only");
|
|
133
|
+
},
|
|
134
|
+
});
|
|
124
135
|
/**
|
|
125
136
|
* Set the "started" property in this event so developers can use runtime
|
|
126
137
|
* features in pipes/hooks attached to this event.
|
|
@@ -138,18 +149,19 @@ class Backend {
|
|
|
138
149
|
// Silent if no version can be found
|
|
139
150
|
}
|
|
140
151
|
global.app = this;
|
|
141
|
-
this.pipe = new
|
|
142
|
-
this.hook = new
|
|
143
|
-
this.config = new
|
|
144
|
-
this.vault = new
|
|
145
|
-
this.controller = new
|
|
146
|
-
this.plugin = new
|
|
147
|
-
this.storage = new
|
|
148
|
-
this.import = new
|
|
149
|
-
this.cluster = new
|
|
150
|
-
this.openApi = new
|
|
151
|
-
this.errors = new
|
|
152
|
-
this.subscription = new
|
|
152
|
+
this.pipe = new index_2.BackendPipe(this);
|
|
153
|
+
this.hook = new index_2.BackendHook(this);
|
|
154
|
+
this.config = new index_2.BackendConfig(this);
|
|
155
|
+
this.vault = new index_2.BackendVault(this);
|
|
156
|
+
this.controller = new index_2.BackendController(this);
|
|
157
|
+
this.plugin = new index_2.BackendPlugin(this);
|
|
158
|
+
this.storage = new index_2.BackendStorage(this);
|
|
159
|
+
this.import = new index_2.BackendImport(this);
|
|
160
|
+
this.cluster = new index_2.BackendCluster();
|
|
161
|
+
this.openApi = new index_2.BackendOpenApi(this);
|
|
162
|
+
this.errors = new index_2.BackendErrors(this);
|
|
163
|
+
this.subscription = new index_2.BackendSubscription(this);
|
|
164
|
+
this.log = new Logger_1.Logger(this.config.content, "kuzzle:app");
|
|
153
165
|
this.kerror = kerror;
|
|
154
166
|
try {
|
|
155
167
|
this.commit = this._readCommit();
|
|
@@ -166,7 +178,6 @@ class Backend {
|
|
|
166
178
|
throw runtimeError.get("already_started", "start");
|
|
167
179
|
}
|
|
168
180
|
this._kuzzle = new kuzzle_1.default(this.config.content);
|
|
169
|
-
this.log = this._kuzzle.log.child(`app`);
|
|
170
181
|
for (const plugin of this.config.content.plugins.common.include) {
|
|
171
182
|
const { default: PluginClass } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
172
183
|
this.plugin.use(new PluginClass(), {
|
|
@@ -246,15 +257,6 @@ class Backend {
|
|
|
246
257
|
}
|
|
247
258
|
return this._sdk;
|
|
248
259
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Cluster node ID
|
|
251
|
-
*/
|
|
252
|
-
get nodeId() {
|
|
253
|
-
if (!this.started) {
|
|
254
|
-
throw runtimeError.get("unavailable_before_start", "nodeId");
|
|
255
|
-
}
|
|
256
|
-
return this._kuzzle.id;
|
|
257
|
-
}
|
|
258
260
|
get _instanceProxy() {
|
|
259
261
|
return {
|
|
260
262
|
api: this._controllers,
|
package/lib/kuzzle/Logger.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { KuzzleConfiguration } from "../../";
|
|
|
6
6
|
export declare class Logger extends KuzzleLogger {
|
|
7
7
|
private warnedForSillyDeprecation;
|
|
8
8
|
private warnedForVerboseDeprecation;
|
|
9
|
-
constructor(kuzzleConfig: KuzzleConfiguration);
|
|
9
|
+
constructor(kuzzleConfig: KuzzleConfiguration, namespace?: string);
|
|
10
10
|
/**
|
|
11
11
|
* Logs a message with the "silly" level.
|
|
12
12
|
*
|
package/lib/kuzzle/Logger.js
CHANGED
|
@@ -26,15 +26,18 @@ const kuzzle_logger_1 = require("kuzzle-logger");
|
|
|
26
26
|
* The Logger class provides logging functionality for Kuzzle.
|
|
27
27
|
*/
|
|
28
28
|
class Logger extends kuzzle_logger_1.KuzzleLogger {
|
|
29
|
-
constructor(kuzzleConfig) {
|
|
29
|
+
constructor(kuzzleConfig, namespace = "kuzzle") {
|
|
30
30
|
const config = kuzzleConfig.server.appLogs;
|
|
31
31
|
const deprecatedConfig = kuzzleConfig.plugins["kuzzle-plugin-logger"];
|
|
32
32
|
const getMergingObject = () => {
|
|
33
33
|
const mergingObject = {};
|
|
34
|
-
mergingObject.namespace =
|
|
34
|
+
mergingObject.namespace = namespace;
|
|
35
35
|
mergingObject.failsafeMode = Boolean(kuzzleConfig.plugins.common.failsafeMode);
|
|
36
|
-
if (global.
|
|
37
|
-
mergingObject.nodeId = global.
|
|
36
|
+
if (global.nodeId) {
|
|
37
|
+
mergingObject.nodeId = global.nodeId;
|
|
38
|
+
}
|
|
39
|
+
if (namespace !== "kuzzle") {
|
|
40
|
+
return mergingObject;
|
|
38
41
|
}
|
|
39
42
|
if (global.kuzzle.asyncStore?.exists() &&
|
|
40
43
|
global.kuzzle.asyncStore?.has("REQUEST")) {
|
|
@@ -74,9 +77,6 @@ class Logger extends kuzzle_logger_1.KuzzleLogger {
|
|
|
74
77
|
if (deprecatedConfig) {
|
|
75
78
|
this.warn("[DEPRECATED] The plugins.kuzzle-plugin-logger configuration is deprecated, use server.logs instead.");
|
|
76
79
|
}
|
|
77
|
-
global.kuzzle.onPipe("kuzzle:shutdown", async () => {
|
|
78
|
-
await this.flush();
|
|
79
|
-
});
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Logs a message with the "silly" level.
|
package/lib/kuzzle/kuzzle.js
CHANGED
|
@@ -73,7 +73,6 @@ const kerror = __importStar(require("../kerror"));
|
|
|
73
73
|
const asyncStore_1 = __importDefault(require("../util/asyncStore"));
|
|
74
74
|
const crypto_1 = require("../util/crypto");
|
|
75
75
|
const mutex_1 = require("../util/mutex");
|
|
76
|
-
const name_generator_1 = require("../util/name-generator");
|
|
77
76
|
const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
|
|
78
77
|
const KuzzleEventEmitter_1 = __importDefault(require("./event/KuzzleEventEmitter"));
|
|
79
78
|
const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
|
|
@@ -152,7 +151,7 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
152
151
|
await this.internalIndex.init();
|
|
153
152
|
await new security_1.default().init();
|
|
154
153
|
// This will init the cluster module if enabled
|
|
155
|
-
|
|
154
|
+
await this.initKuzzleNode();
|
|
156
155
|
this.vault = vault_1.default.load(options.vaultKey, options.secretsFile);
|
|
157
156
|
await this.validation.init();
|
|
158
157
|
await this.tokenManager.init();
|
|
@@ -196,16 +195,13 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
196
195
|
* This will init the cluster if it's enabled.
|
|
197
196
|
*/
|
|
198
197
|
async initKuzzleNode() {
|
|
199
|
-
let id;
|
|
200
198
|
if (this.config.cluster.enabled) {
|
|
201
|
-
|
|
199
|
+
await new cluster_1.default().init();
|
|
202
200
|
this.log.info("[✔] Cluster initialized");
|
|
203
201
|
}
|
|
204
202
|
else {
|
|
205
|
-
id = name_generator_1.NameGenerator.generateRandomName({ prefix: "knode" });
|
|
206
203
|
this.log.info("[X] Cluster disabled: single node mode.");
|
|
207
204
|
}
|
|
208
|
-
return id;
|
|
209
205
|
}
|
|
210
206
|
/**
|
|
211
207
|
* Gracefully exits after processing remaining requests
|
|
@@ -225,6 +221,9 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
225
221
|
await bluebird_1.default.delay(1000);
|
|
226
222
|
}
|
|
227
223
|
this.log.info("Halted.");
|
|
224
|
+
// flush both application and Kuzzle core loggers before leaving (Could happen even if some core/application components are not initialized)
|
|
225
|
+
await this?.log?.flush?.();
|
|
226
|
+
await this?.pluginsManager?.application?.log?.flush?.();
|
|
228
227
|
process.exit(0);
|
|
229
228
|
}
|
|
230
229
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.46.0",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|