vona-module-a-startup 5.0.25 → 5.0.27

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/index.js CHANGED
@@ -34,42 +34,13 @@ let ServiceStartup = (_dec$3 = Service(), _dec2$3 = BeanInfo({
34
34
 
35
35
  // version init : force: should be false
36
36
  if (this.app.meta.isTest || this.app.meta.isDev) {
37
- const instanceName = '';
38
- await this.bean.executor.newCtx(async () => {
39
- await this.$scope.instance.service.instance.instanceStartup(instanceName, {
40
- force: false
41
- });
42
- }, {
43
- dbInfo: {
44
- level: 1
45
- },
46
- instanceName
47
- });
37
+ await this._appReadyInstanceStartup('', true);
48
38
  } else {
49
- // all instances
50
- const instances = await this.bean.executor.newCtx(async () => {
51
- return await this.bean.instance.list();
52
- }, {
53
- dbInfo: {
54
- level: 1
55
- }
56
- });
57
- for (const instance of instances) {
58
- const instanceName = instance.name;
59
- // need not await
60
- const res = this.bean.executor.newCtx(async () => {
61
- await this.$scope.instance.service.instance.instanceStartup(instanceName, {
62
- force: false
63
- });
64
- }, {
65
- dbInfo: {
66
- level: 1
67
- },
68
- instanceName
69
- });
70
- if (this.app.config.server.listen.disable) {
71
- await res;
72
- }
39
+ // only start static instances (defined in config)
40
+ for (const configInstanceBase of this.app.config.instances) {
41
+ // need not await for prod
42
+ const wait = this.app.config.server.listen.disable;
43
+ await this._appReadyInstanceStartup(configInstanceBase.name, wait);
73
44
  }
74
45
  }
75
46
 
@@ -86,6 +57,14 @@ let ServiceStartup = (_dec$3 = Service(), _dec2$3 = BeanInfo({
86
57
  });
87
58
  }
88
59
  }
60
+ async _appReadyInstanceStartup(instanceName, wait) {
61
+ const res = this.$scope.instance.service.instance.instanceStartupIsolate(instanceName, {
62
+ force: false
63
+ });
64
+ if (wait) {
65
+ await res;
66
+ }
67
+ }
89
68
  async runStartup(startupName, instanceName, options) {
90
69
  const startup = this.bean.onion.startup.onionsNormal[startupName];
91
70
  const startupOptions = startup.beanOptions.options;
@@ -5,6 +5,7 @@ import { BeanBase } from 'vona';
5
5
  export declare class ServiceStartup extends BeanBase {
6
6
  appStart(): Promise<void>;
7
7
  appReady(): Promise<void>;
8
+ private _appReadyInstanceStartup;
8
9
  runStartup(startupName: string, instanceName?: keyof IInstanceRecord | null, options?: IInstanceStartupOptions): Promise<void>;
9
10
  _runStartupLock<T extends keyof IStartupRecord>(startup: IOnionSlice<IStartupRecord, T>, instanceName?: keyof IInstanceRecord | null, options?: IInstanceStartupOptions): Promise<void>;
10
11
  _runStartupInner<T extends keyof IStartupRecord>(startup: IOnionSlice<IStartupRecord, T>, instanceName?: keyof IInstanceRecord | null, options?: IInstanceStartupOptions): Promise<void>;
@@ -1,12 +1,12 @@
1
1
  import type { OmitNever } from 'vona';
2
2
  import type { ConfigInstanceBase } from 'vona-module-a-instance';
3
- import type { IOnionOptionsDeps, IOnionOptionsEnable, ServiceOnion } from 'vona-module-a-onion';
3
+ import type { IOnionOptionsDeps, ServiceOnion, TypeOnionOptionsEnableSimple } from 'vona-module-a-onion';
4
4
  export interface IStartupRecord {
5
5
  }
6
6
  export interface IStartupExecute {
7
7
  execute: (options?: IInstanceStartupOptions) => Promise<void>;
8
8
  }
9
- export interface IDecoratorStartupOptions extends IOnionOptionsEnable, IOnionOptionsDeps<keyof IStartupRecord> {
9
+ export interface IDecoratorStartupOptions extends TypeOnionOptionsEnableSimple, IOnionOptionsDeps<keyof IStartupRecord> {
10
10
  instance?: boolean;
11
11
  debounce?: boolean | number;
12
12
  transaction?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-startup",
3
3
  "type": "module",
4
- "version": "5.0.25",
4
+ "version": "5.0.27",
5
5
  "title": "a-startup",
6
6
  "vonaModule": {
7
7
  "dependencies": {},