@nocobase/server 2.0.0-alpha.24 → 2.0.0-alpha.25

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.
@@ -61,6 +61,8 @@ export declare class AppSupervisor extends EventEmitter implements AsyncEmitter
61
61
  touchApp(appName: string): void;
62
62
  addApp(app: Application): Application<import("./application").DefaultState, import("./application").DefaultContext>;
63
63
  getAppsNames(): Promise<string[]>;
64
+ startApp(appName: string): Promise<void>;
65
+ stopApp(appName: string): Promise<void>;
64
66
  removeApp(appName: string): Promise<void>;
65
67
  subApps(): Application<import("./application").DefaultState, import("./application").DefaultContext>[];
66
68
  on(eventName: string | symbol, listener: (...args: any[]) => void): this;
@@ -179,12 +179,25 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
179
179
  const apps = Object.values(this.apps);
180
180
  return apps.map((app) => app.name);
181
181
  }
182
+ async startApp(appName) {
183
+ const appInstance = await _AppSupervisor.getInstance().getApp(appName);
184
+ await appInstance.runCommand("start", "--quickstart");
185
+ }
186
+ async stopApp(appName) {
187
+ if (!this.apps[appName]) {
188
+ console.log(`app ${appName} not exists`);
189
+ return;
190
+ }
191
+ await this.apps[appName].runCommand("stop");
192
+ this.apps[appName] = null;
193
+ }
182
194
  async removeApp(appName) {
183
195
  if (!this.apps[appName]) {
184
196
  console.log(`app ${appName} not exists`);
185
197
  return;
186
198
  }
187
199
  await this.apps[appName].runCommand("destroy");
200
+ this.apps[appName] = null;
188
201
  }
189
202
  subApps() {
190
203
  return Object.values(this.apps).filter((app) => app.name !== "main");
@@ -202,7 +202,15 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
202
202
  res.end(JSON.stringify({ error }));
203
203
  }
204
204
  responseErrorWithCode(code, res, options) {
205
+ const log = this.getLogger(options.appName, res);
205
206
  const error = (0, import_errors.applyErrorWithArgs)((0, import_errors.getErrorWithCode)(code), options);
207
+ log.error(error.message, {
208
+ method: "responseErrorWithCode",
209
+ code,
210
+ error,
211
+ statusCode: res.statusCode,
212
+ appName: options.appName
213
+ });
206
214
  this.responseError(res, error);
207
215
  }
208
216
  async requestHandler(req, res) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.0.0-alpha.24",
3
+ "version": "2.0.0-alpha.25",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,20 +10,20 @@
10
10
  "@koa/cors": "^5.0.0",
11
11
  "@koa/multer": "^3.1.0",
12
12
  "@koa/router": "^13.1.0",
13
- "@nocobase/acl": "2.0.0-alpha.24",
14
- "@nocobase/actions": "2.0.0-alpha.24",
15
- "@nocobase/auth": "2.0.0-alpha.24",
16
- "@nocobase/cache": "2.0.0-alpha.24",
17
- "@nocobase/data-source-manager": "2.0.0-alpha.24",
18
- "@nocobase/database": "2.0.0-alpha.24",
19
- "@nocobase/evaluators": "2.0.0-alpha.24",
20
- "@nocobase/lock-manager": "2.0.0-alpha.24",
21
- "@nocobase/logger": "2.0.0-alpha.24",
22
- "@nocobase/resourcer": "2.0.0-alpha.24",
23
- "@nocobase/sdk": "2.0.0-alpha.24",
24
- "@nocobase/snowflake-id": "2.0.0-alpha.24",
25
- "@nocobase/telemetry": "2.0.0-alpha.24",
26
- "@nocobase/utils": "2.0.0-alpha.24",
13
+ "@nocobase/acl": "2.0.0-alpha.25",
14
+ "@nocobase/actions": "2.0.0-alpha.25",
15
+ "@nocobase/auth": "2.0.0-alpha.25",
16
+ "@nocobase/cache": "2.0.0-alpha.25",
17
+ "@nocobase/data-source-manager": "2.0.0-alpha.25",
18
+ "@nocobase/database": "2.0.0-alpha.25",
19
+ "@nocobase/evaluators": "2.0.0-alpha.25",
20
+ "@nocobase/lock-manager": "2.0.0-alpha.25",
21
+ "@nocobase/logger": "2.0.0-alpha.25",
22
+ "@nocobase/resourcer": "2.0.0-alpha.25",
23
+ "@nocobase/sdk": "2.0.0-alpha.25",
24
+ "@nocobase/snowflake-id": "2.0.0-alpha.25",
25
+ "@nocobase/telemetry": "2.0.0-alpha.25",
26
+ "@nocobase/utils": "2.0.0-alpha.25",
27
27
  "@types/decompress": "4.2.7",
28
28
  "@types/ini": "^1.3.31",
29
29
  "@types/koa-send": "^4.1.3",
@@ -59,5 +59,5 @@
59
59
  "@types/serve-handler": "^6.1.1",
60
60
  "@types/ws": "^8.5.5"
61
61
  },
62
- "gitHead": "4e6d1ae61143f01aba213355b4c416aab4d64077"
62
+ "gitHead": "8ce1972206272bd1723db193abd0425c532c5687"
63
63
  }