dynapm 1.0.2 → 1.0.3

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/README_zh.md CHANGED
@@ -12,7 +12,12 @@
12
12
 
13
13
  ```bash
14
14
  pnpm i dynapm -g
15
- dynapm ./apps.json
15
+ ```
16
+ 在要执行命令的目录下创建一个 dynapm.config.ts 配置文件,内容如下
17
+ ```ts
18
+ export default {
19
+
20
+ }
16
21
  ```
17
22
 
18
23
  ## 引言
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/dist/src/index.js CHANGED
@@ -38,14 +38,16 @@ function getBase200(base) {
38
38
  }
39
39
  async function runCheck(config) {
40
40
  const time1 = Date.now();
41
- if ('getBase200' === config.runCheck) while(true){
42
- if (Date.now() - time1 > config.maxAwaitLaunchTime) throw new Error(`等待启动的时间超过了配置的 maxAwaitLaunchTime :${config.maxAwaitLaunchTime}`);
43
- if (await getBase200(config.base)) return true;
44
- }
45
- else {
46
- config.runCheck;
47
- throw new Error(`尚未支持的 config check : ${config.runCheck}`);
41
+ if ('getBase200' === config.runCheck) {
42
+ while(true){
43
+ if (Date.now() - time1 > config.maxAwaitLaunchTime) throw new Error(`等待启动的时间超过了配置的 maxAwaitLaunchTime :${config.maxAwaitLaunchTime}`);
44
+ if (!await getBase200(config.base)) continue;
45
+ break;
46
+ }
47
+ return true;
48
48
  }
49
+ config.runCheck;
50
+ throw new Error(`尚未支持的 config check : ${config.runCheck}`);
49
51
  }
50
52
  const pm2Map = {
51
53
  '127.0.0.1': {
@@ -0,0 +1,20 @@
1
+ import type { StartOptions } from 'pm2';
2
+ export type DynaPM_Config = {
3
+ [host: string]: DynaPM_items;
4
+ };
5
+ export type DynaPM_items = pm2ItemConfig;
6
+ type baseConfig = {
7
+ base: string;
8
+ latestTime: number;
9
+ stopTime: number;
10
+ maxAwaitLaunchTime: number;
11
+ runCheck: runCheck;
12
+ runStatus: 'launching' | 'running' | 'stop' | 'unknown';
13
+ };
14
+ export type runCheck = 'getBase200';
15
+ export type pm2ItemConfig = baseConfig & {
16
+ pm2Options: StartOptions & {
17
+ name: string;
18
+ };
19
+ };
20
+ export {};
@@ -0,0 +1 @@
1
+ export type ManageType = {};
@@ -0,0 +1,19 @@
1
+ import type { pm2ItemConfig } from './configDef';
2
+ export declare const pm2Map: {
3
+ '127.0.0.1': {
4
+ base: string;
5
+ latestTime: number;
6
+ stopTime: number;
7
+ maxAwaitLaunchTime: number;
8
+ runCheck: "getBase200";
9
+ runStatus: "launching" | "running" | "stop" | "unknown";
10
+ pm2Options: {
11
+ name: string;
12
+ script: string;
13
+ interpreter: string;
14
+ };
15
+ };
16
+ };
17
+ export declare const pm2Manage: {
18
+ start(target: pm2ItemConfig): Promise<boolean>;
19
+ };
@@ -0,0 +1,3 @@
1
+ import type { DynaPM_items } from './configDef';
2
+ export declare function getBase200(base: string): Promise<boolean>;
3
+ export declare function runCheck(config: DynaPM_items): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynapm",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "DynaPM is a dynamic start-stop application management tool with serverless-like features designed for resource-constrained environments. It starts and stops programs on demand, optimizes resource usage, and is suitable for private deployments. ",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1",
11
11
  "build": "rslib build",
12
- "publish2npm": "pnpm tsx ./script/updateVersion.ts && npm publish --registry=https://registry.npmjs.org",
12
+ "publish2npm": "pnpm build && pnpm tsx ./script/updateVersion.ts && npm publish --registry=https://registry.npmjs.org",
13
13
  "runTestServer": "pnpm tsx ./test/server1.ts"
14
14
  },
15
15
  "files": [
@@ -29,13 +29,15 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@fastify/reply-from": "^12.0.2",
32
+ "c12": "^2.0.4",
32
33
  "fastify": "^5.2.1",
33
34
  "pm2": "^5.4.3"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@rslib/core": "^0.4.1",
37
- "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.51.0",
38
38
  "@types/node": "^22.13.4",
39
- "tsx": "^4.19.3"
39
+ "tsx": "^4.19.3",
40
+ "typescript": "^5.7.3",
41
+ "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.51.0"
40
42
  }
41
43
  }