befly-tpl 3.4.14 → 3.4.15
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/package.json +4 -5
- package/pm2.config.cjs +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-tpl",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.15",
|
|
4
4
|
"description": "Befly 3.0 TypeScript Template",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "bun run --env-file=.env.development main.ts",
|
|
12
12
|
"start": "bun run --env-file=.env.production main.ts",
|
|
13
|
-
"pm2
|
|
14
|
-
"pm2:dev": "pm2 start pm2.config.js --env development",
|
|
13
|
+
"pm2": "pm2 start pm2.config.cjs",
|
|
15
14
|
"sync:dev": "NODE_ENV=development befly sync",
|
|
16
15
|
"sync:prod": "NODE_ENV=production befly sync"
|
|
17
16
|
},
|
|
@@ -32,10 +31,10 @@
|
|
|
32
31
|
],
|
|
33
32
|
"type": "module",
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"befly": "^3.4.
|
|
34
|
+
"befly": "^3.4.14"
|
|
36
35
|
},
|
|
37
36
|
"engines": {
|
|
38
37
|
"bun": ">=1.3.0"
|
|
39
38
|
},
|
|
40
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "8ced9f183b280460e8136eb00985c0fb83e63bc1"
|
|
41
40
|
}
|
package/pm2.config.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PM2 进程管理配置文件(CommonJS 格式)
|
|
3
|
+
* 使用 Bun 的 --env-file 参数显式指定环境变量文件
|
|
4
|
+
*
|
|
5
|
+
* 使用方法:
|
|
6
|
+
* 1. 启动:pm2 start pm2.config.cjs
|
|
7
|
+
* 2. 查看状态:pm2 status
|
|
8
|
+
* 3. 查看日志:pm2 logs befly
|
|
9
|
+
* 4. 重启:pm2 restart befly
|
|
10
|
+
* 5. 停止:pm2 stop befly
|
|
11
|
+
* 6. 删除:pm2 delete befly
|
|
12
|
+
* 7. 保存配置:pm2 save
|
|
13
|
+
* 8. 开机自启:pm2 startup
|
|
14
|
+
*
|
|
15
|
+
* 环境变量加载:
|
|
16
|
+
* - 默认使用生产环境:--env-file=.env.production
|
|
17
|
+
*
|
|
18
|
+
* 注意:PM2 配置文件必须使用 CommonJS 格式(.cjs),不支持 ESM
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
apps: [
|
|
23
|
+
{
|
|
24
|
+
name: 'befly',
|
|
25
|
+
script: './main.ts',
|
|
26
|
+
interpreter: 'bun',
|
|
27
|
+
interpreter_args: '--env-file=.env.production',
|
|
28
|
+
|
|
29
|
+
// 集群模式配置
|
|
30
|
+
instances: 4, // 实例数量,可设置为 'max' 使用所有 CPU
|
|
31
|
+
exec_mode: 'cluster', // 集群模式
|
|
32
|
+
|
|
33
|
+
// 自动重启配置
|
|
34
|
+
autorestart: true,
|
|
35
|
+
watch: false,
|
|
36
|
+
max_memory_restart: '1G', // 内存超过 1G 自动重启
|
|
37
|
+
|
|
38
|
+
// 日志配置
|
|
39
|
+
error_file: './logs/pm2-error.log',
|
|
40
|
+
out_file: './logs/pm2-out.log',
|
|
41
|
+
log_date_format: 'YYYY-MM-DD HH:mm:ss',
|
|
42
|
+
merge_logs: true
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|