@flink-app/flink 0.12.1-alpha.3 → 0.12.1-alpha.4
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/dist/src/FlinkApp.d.ts +2 -0
- package/dist/src/FlinkApp.js +31 -1
- package/package.json +2 -2
- package/src/FlinkApp.ts +24 -1
package/dist/src/FlinkApp.d.ts
CHANGED
|
@@ -171,6 +171,7 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
171
171
|
private rawContentTypes?;
|
|
172
172
|
private schedulingOptions?;
|
|
173
173
|
private disableHttpServer;
|
|
174
|
+
private expressServer;
|
|
174
175
|
private repos;
|
|
175
176
|
/**
|
|
176
177
|
* Internal cache used to track registered handlers and potentially any overlapping routes
|
|
@@ -181,6 +182,7 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
181
182
|
constructor(opts: FlinkOptions);
|
|
182
183
|
get ctx(): C;
|
|
183
184
|
start(): Promise<this>;
|
|
185
|
+
stop(): Promise<void>;
|
|
184
186
|
/**
|
|
185
187
|
* Manually registers a handler.
|
|
186
188
|
*
|
package/dist/src/FlinkApp.js
CHANGED
|
@@ -231,7 +231,7 @@ var FlinkApp = /** @class */ (function () {
|
|
|
231
231
|
this.started = true;
|
|
232
232
|
}
|
|
233
233
|
else {
|
|
234
|
-
(_d = this.expressApp) === null || _d === void 0 ? void 0 : _d.listen(this.port, function () {
|
|
234
|
+
this.expressServer = (_d = this.expressApp) === null || _d === void 0 ? void 0 : _d.listen(this.port, function () {
|
|
235
235
|
FlinkLog_1.log.fontColorLog("magenta", "\u26A1\uFE0F HTTP server '".concat(_this.name, "' is running and waiting for connections on ").concat(_this.port));
|
|
236
236
|
_this.started = true;
|
|
237
237
|
});
|
|
@@ -241,6 +241,36 @@ var FlinkApp = /** @class */ (function () {
|
|
|
241
241
|
});
|
|
242
242
|
});
|
|
243
243
|
};
|
|
244
|
+
FlinkApp.prototype.stop = function () {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
var _this = this;
|
|
247
|
+
return __generator(this, function (_a) {
|
|
248
|
+
switch (_a.label) {
|
|
249
|
+
case 0:
|
|
250
|
+
FlinkLog_1.log.info("🛑 Stopping Flink app...");
|
|
251
|
+
if (!this.scheduler) return [3 /*break*/, 2];
|
|
252
|
+
return [4 /*yield*/, this.scheduler.stop()];
|
|
253
|
+
case 1:
|
|
254
|
+
_a.sent();
|
|
255
|
+
_a.label = 2;
|
|
256
|
+
case 2:
|
|
257
|
+
if (this.expressServer) {
|
|
258
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
259
|
+
var int = setTimeout(function () {
|
|
260
|
+
reject("Failed to stop HTTP server in time");
|
|
261
|
+
}, 2000);
|
|
262
|
+
_this.expressServer.close(function () {
|
|
263
|
+
clearInterval(int);
|
|
264
|
+
FlinkLog_1.log.info("HTTP server stopped");
|
|
265
|
+
resolve();
|
|
266
|
+
});
|
|
267
|
+
})];
|
|
268
|
+
}
|
|
269
|
+
return [2 /*return*/];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
244
274
|
/**
|
|
245
275
|
* Manually registers a handler.
|
|
246
276
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/flink",
|
|
3
|
-
"version": "0.12.1-alpha.
|
|
3
|
+
"version": "0.12.1-alpha.4",
|
|
4
4
|
"description": "Typescript only framework for creating REST-like APIs on top of Express and mongodb",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"rimraf": "^3.0.2",
|
|
67
67
|
"ts-node": "^9.1.1"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "8f06a4ab98e7179322d36546756d4305fd196f5a"
|
|
70
70
|
}
|
package/src/FlinkApp.ts
CHANGED
|
@@ -234,6 +234,7 @@ export class FlinkApp<C extends FlinkContext> {
|
|
|
234
234
|
private rawContentTypes?: string[];
|
|
235
235
|
private schedulingOptions?: FlinkOptions["scheduling"];
|
|
236
236
|
private disableHttpServer = false;
|
|
237
|
+
private expressServer: any; // for simplicity, we don't want to import types from express/node here
|
|
237
238
|
|
|
238
239
|
private repos: { [x: string]: FlinkRepo<C, any> } = {};
|
|
239
240
|
|
|
@@ -367,7 +368,7 @@ export class FlinkApp<C extends FlinkContext> {
|
|
|
367
368
|
log.info("🚧 HTTP server is disabled, but flink app is running");
|
|
368
369
|
this.started = true;
|
|
369
370
|
} else {
|
|
370
|
-
this.expressApp?.listen(this.port, () => {
|
|
371
|
+
this.expressServer = this.expressApp?.listen(this.port, () => {
|
|
371
372
|
log.fontColorLog("magenta", `⚡️ HTTP server '${this.name}' is running and waiting for connections on ${this.port}`);
|
|
372
373
|
this.started = true;
|
|
373
374
|
});
|
|
@@ -376,6 +377,28 @@ export class FlinkApp<C extends FlinkContext> {
|
|
|
376
377
|
return this;
|
|
377
378
|
}
|
|
378
379
|
|
|
380
|
+
async stop() {
|
|
381
|
+
log.info("🛑 Stopping Flink app...");
|
|
382
|
+
|
|
383
|
+
if (this.scheduler) {
|
|
384
|
+
await this.scheduler.stop();
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (this.expressServer) {
|
|
388
|
+
return new Promise<void>((resolve, reject) => {
|
|
389
|
+
const int = setTimeout(() => {
|
|
390
|
+
reject("Failed to stop HTTP server in time");
|
|
391
|
+
}, 2000);
|
|
392
|
+
|
|
393
|
+
this.expressServer.close(() => {
|
|
394
|
+
clearInterval(int);
|
|
395
|
+
log.info("HTTP server stopped");
|
|
396
|
+
resolve();
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
379
402
|
/**
|
|
380
403
|
* Manually registers a handler.
|
|
381
404
|
*
|