vona-module-a-startup 5.0.24 → 5.0.26

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;
@@ -184,10 +163,10 @@ const __ThisModule__ = 'a-startup';
184
163
 
185
164
  class Monkey extends BeanSimple {
186
165
  async appStart() {
187
- await this.bean.scope(__ThisModule__).service.startup.appStart();
166
+ await this.app.scope(__ThisModule__).service.startup.appStart();
188
167
  }
189
168
  async appReady() {
190
- await this.bean.scope(__ThisModule__).service.startup.appReady();
169
+ await this.app.scope(__ThisModule__).service.startup.appReady();
191
170
  }
192
171
  }
193
172
 
@@ -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>;
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.24",
4
+ "version": "5.0.26",
5
5
  "title": "a-startup",
6
6
  "vonaModule": {
7
7
  "dependencies": {},