@midwayjs/bootstrap 3.12.3 → 3.13.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.
@@ -1,5 +1,5 @@
1
1
  import { IMidwayBootstrapOptions, IMidwayContainer } from '@midwayjs/core';
2
- import { IMidwayLogger } from '@midwayjs/logger';
2
+ import { ILogger } from '@midwayjs/logger';
3
3
  export declare class BootstrapStarter {
4
4
  protected appDir: string;
5
5
  protected baseDir: string;
@@ -16,8 +16,9 @@ export declare class BootstrapStarter {
16
16
  }
17
17
  export declare class Bootstrap {
18
18
  protected static starter: BootstrapStarter;
19
- protected static logger: IMidwayLogger;
19
+ protected static logger: ILogger;
20
20
  protected static configured: boolean;
21
+ protected static bootstrapLoggerFactory: import("@midwayjs/logger").LoggerFactory;
21
22
  /**
22
23
  * set global configuration for midway
23
24
  * @param configuration
package/dist/bootstrap.js CHANGED
@@ -41,6 +41,7 @@ class BootstrapStarter {
41
41
  }
42
42
  this.applicationContext = await (0, core_1.initializeGlobalApplicationContext)({
43
43
  asyncContextManager: (0, async_hooks_context_manager_1.createContextManager)(),
44
+ loggerFactory: logger_1.loggers,
44
45
  ...this.globalOptions,
45
46
  });
46
47
  return this.applicationContext;
@@ -86,15 +87,22 @@ class Bootstrap {
86
87
  * @param configuration
87
88
  */
88
89
  static configure(configuration = {}) {
89
- var _a;
90
90
  this.configured = true;
91
91
  if (!this.logger && !configuration.logger) {
92
- this.logger = new logger_1.MidwayBaseLogger({
93
- disableError: true,
94
- disableFile: true,
92
+ this.logger = this.bootstrapLoggerFactory.createLogger('bootstrap', {
93
+ enableError: false,
94
+ enableFile: false,
95
+ enableConsole: true,
95
96
  });
96
97
  if (configuration.logger === false) {
97
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a['disableConsole']();
98
+ if (this.logger['disableConsole']) {
99
+ // v2
100
+ this.logger['disableConsole']();
101
+ }
102
+ else {
103
+ // v3
104
+ this.logger['level'] = 'none';
105
+ }
98
106
  }
99
107
  configuration.logger = this.logger;
100
108
  }
@@ -153,7 +161,7 @@ class Bootstrap {
153
161
  static reset() {
154
162
  this.configured = false;
155
163
  this.starter = null;
156
- this.logger.close();
164
+ this.bootstrapLoggerFactory.close();
157
165
  }
158
166
  /**
159
167
  * on bootstrap receive a exit signal
@@ -212,4 +220,5 @@ class Bootstrap {
212
220
  }
213
221
  exports.Bootstrap = Bootstrap;
214
222
  Bootstrap.configured = false;
223
+ Bootstrap.bootstrapLoggerFactory = new logger_1.MidwayLoggerContainer();
215
224
  //# sourceMappingURL=bootstrap.js.map
@@ -1,19 +1,19 @@
1
1
  import { ForkOptions } from '../interface';
2
2
  import type { IEventBus, EventBusOptions } from '@midwayjs/event-bus';
3
- export declare abstract class AbstractForkManager<T, ClusterOptions extends ForkOptions> {
3
+ export declare abstract class AbstractForkManager<Worker, ClusterOptions extends ForkOptions> {
4
4
  readonly options: ClusterOptions;
5
5
  private reforks;
6
6
  private disconnectCount;
7
7
  private unexpectedCount;
8
8
  private disconnects;
9
9
  private hub;
10
- protected workers: Map<string, T>;
11
- protected eventBus: IEventBus<T>;
10
+ protected workers: Map<string, Worker>;
11
+ protected eventBus: IEventBus<Worker>;
12
12
  private isClosing;
13
13
  private exitListener;
14
14
  protected constructor(options: ClusterOptions);
15
15
  start(): Promise<void>;
16
- protected tryToRefork(oldWorker: T): void;
16
+ protected tryToRefork(oldWorker: Worker): void;
17
17
  /**
18
18
  * allow refork
19
19
  */
@@ -25,7 +25,7 @@ export declare abstract class AbstractForkManager<T, ClusterOptions extends Fork
25
25
  /**
26
26
  * unexpectedExit default handler
27
27
  */
28
- protected onUnexpected(worker: T, code: any, signal: any): void;
28
+ protected onUnexpected(worker: Worker, code: any, signal: any): void;
29
29
  /**
30
30
  * reachReforkLimit default handler
31
31
  */
@@ -33,7 +33,7 @@ export declare abstract class AbstractForkManager<T, ClusterOptions extends Fork
33
33
  protected killWorker(worker: any, timeout: any): Promise<void>;
34
34
  stop(timeout?: number): Promise<void>;
35
35
  hasWorker(workerId: string): boolean;
36
- getWorker(workerId: string): T;
36
+ getWorker(workerId: string): Worker;
37
37
  getWorkerIds(): string[];
38
38
  onStop(exitListener: any): void;
39
39
  protected bindClose(): void;
@@ -47,13 +47,13 @@ export declare abstract class AbstractForkManager<T, ClusterOptions extends Fork
47
47
  * @param code
48
48
  */
49
49
  private onMasterExit;
50
- abstract createWorker(oldWorker?: T): T;
51
- abstract bindWorkerDisconnect(listener: (worker: T) => void): void;
52
- abstract bindWorkerExit(listener: (worker: T, code: any, signal: any) => void): void;
53
- abstract getWorkerId(worker: T): string;
54
- abstract isWorkerDead(worker: T): boolean;
55
- abstract closeWorker(worker: T): any;
56
- abstract createEventBus(eventBusOptions: EventBusOptions): IEventBus<T>;
50
+ abstract createWorker(oldWorker?: Worker): Worker;
51
+ abstract bindWorkerDisconnect(listener: (worker: Worker) => void): void;
52
+ abstract bindWorkerExit(listener: (worker: Worker, code: any, signal: any) => void): void;
53
+ abstract getWorkerId(worker: Worker): string;
54
+ abstract isWorkerDead(worker: Worker): boolean;
55
+ abstract closeWorker(worker: Worker): any;
56
+ abstract createEventBus(eventBusOptions: EventBusOptions<Worker>): IEventBus<Worker>;
57
57
  abstract isPrimary(): boolean;
58
58
  }
59
59
  //# sourceMappingURL=base.d.ts.map
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@midwayjs/bootstrap",
3
- "version": "3.12.3",
3
+ "version": "3.13.0",
4
4
  "description": "midwayjs bootstrap",
5
- "main": "dist/index",
5
+ "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
@@ -21,12 +21,12 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@midwayjs/async-hooks-context-manager": "^3.12.3",
25
- "@midwayjs/event-bus": "1.7.0"
24
+ "@midwayjs/async-hooks-context-manager": "^3.13.0",
25
+ "@midwayjs/event-bus": "1.9.4"
26
26
  },
27
27
  "devDependencies": {
28
- "@midwayjs/core": "^3.12.3",
29
- "@midwayjs/logger": "^2.15.0",
28
+ "@midwayjs/core": "^3.13.0",
29
+ "@midwayjs/logger": "^3.0.0",
30
30
  "request": "2.88.2",
31
31
  "socket.io-client": "4.7.2"
32
32
  },
@@ -38,5 +38,5 @@
38
38
  "engines": {
39
39
  "node": ">=12.11.0"
40
40
  },
41
- "gitHead": "0b6638726c4722d5a6ee8075fea0a0b68378452c"
41
+ "gitHead": "9f55734afa5b08dcf46bc89493ec8edaa8c6202b"
42
42
  }