Compare commits

...

2 Commits

Author SHA1 Message Date
58ff276e10 Merge branch 'bugfix' of http://git.legu.cc/qixin/HJ_Server into bugfix 2023-12-19 17:00:42 +08:00
11e5f17b20 增加gc Test 2023-12-19 17:00:25 +08:00
7 changed files with 145 additions and 19 deletions

View File

@ -60,6 +60,8 @@ const localApps = [
instances: instancesNum,
// 传递给脚本的参数
args: '-serverType msg',
//允许强制gc
node_args: '--expose-gc',
// 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。
watch: false,
// 不用监听的文件
@ -86,6 +88,8 @@ const crossApps = [
cwd: './',
// 传递给脚本的参数
args: '-serverType cross',
//允许强制gc
node_args: '--expose-gc',
// 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。
watch: false,
// 不用监听的文件

31
package-lock.json generated
View File

@ -11,6 +11,7 @@
"axios": "^1.4.0",
"crypto-js": "^4.1.1",
"express": "^4.18.2",
"heapdump": "^0.3.15",
"ioredis": "^5.3.2",
"json5": "^2.2.3",
"mathjs": "^11.4.0",
@ -2545,6 +2546,18 @@
"he": "bin/he"
}
},
"node_modules/heapdump": {
"version": "0.3.15",
"resolved": "https://registry.npmjs.org/heapdump/-/heapdump-0.3.15.tgz",
"integrity": "sha512-n8aSFscI9r3gfhOcAECAtXFaQ1uy4QSke6bnaL+iymYZ/dWs9cqDqHM+rALfsHUwukUbxsdlECZ0pKmJdQ/4OA==",
"hasInstallScript": true,
"dependencies": {
"nan": "^2.13.2"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/http-basic": {
"version": "8.1.3",
"resolved": "https://registry.npmmirror.com/http-basic/-/http-basic-8.1.3.tgz",
@ -3199,6 +3212,11 @@
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true
},
"node_modules/nan": {
"version": "2.18.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz",
"integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w=="
},
"node_modules/nanoid": {
"version": "3.3.1",
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.1.tgz",
@ -6645,6 +6663,14 @@
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true
},
"heapdump": {
"version": "0.3.15",
"resolved": "https://registry.npmjs.org/heapdump/-/heapdump-0.3.15.tgz",
"integrity": "sha512-n8aSFscI9r3gfhOcAECAtXFaQ1uy4QSke6bnaL+iymYZ/dWs9cqDqHM+rALfsHUwukUbxsdlECZ0pKmJdQ/4OA==",
"requires": {
"nan": "^2.13.2"
}
},
"http-basic": {
"version": "8.1.3",
"resolved": "https://registry.npmmirror.com/http-basic/-/http-basic-8.1.3.tgz",
@ -7163,6 +7189,11 @@
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true
},
"nan": {
"version": "2.18.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz",
"integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w=="
},
"nanoid": {
"version": "3.3.1",
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.1.tgz",

View File

@ -37,6 +37,7 @@
"axios": "^1.4.0",
"crypto-js": "^4.1.1",
"express": "^4.18.2",
"heapdump": "^0.3.15",
"ioredis": "^5.3.2",
"json5": "^2.2.3",
"mathjs": "^11.4.0",

View File

@ -0,0 +1,23 @@
import { ApiCall } from "tsrpc";
import { Reqheapdump, Resheapdump } from "../../monopoly/protocols/games/Ptlheapdump";
var heapdump = require('heapdump');
export default async function (call: ApiCall<Reqheapdump, Resheapdump>) {
if(call.req.act == "heapdump"){
let name = Date.now() + '.heapsnapshot'
heapdump.writeSnapshot(name);
call.succ({
code:200,
data:name
})
}
if(call.req.act == "gc"){
global.gc();
call.succ({
code:200,
data:"gc..."
})
}
}

View File

@ -0,0 +1,18 @@
import { StringTypeSchema } from "tsbuffer-schema";
/**
*
*/
export type Reqheapdump = {
act:string,
data:any
};
export type Resheapdump = {
/**
*
*/
code: number
data: any;
};

View File

@ -1,6 +1,7 @@
import { ServiceProto } from 'tsrpc-proto';
import { Reqsendemail, Ressendemail } from './email/Ptlsendemail';
import { Reqdeploy, Resdeploy } from './games/Ptldeploy';
import { Reqheapdump, Resheapdump } from './games/Ptlheapdump';
import { Reqmetrics, Resmetrics } from './games/Ptlmetrics';
import { Reqnotification, Resnotification } from './games/Ptlnotification';
import { Reqopen, Resopen } from './games/Ptlopen';
@ -31,6 +32,10 @@ export interface ServiceType {
req: Reqdeploy,
res: Resdeploy
},
"games/heapdump": {
req: Reqheapdump,
res: Resheapdump
},
"games/metrics": {
req: Reqmetrics,
res: Resmetrics
@ -127,96 +132,101 @@ export const serviceProto: ServiceProto<ServiceType> = {
},
{
"id": 2,
"name": "games/metrics",
"name": "games/heapdump",
"type": "api"
},
{
"id": 3,
"name": "games/notification",
"name": "games/metrics",
"type": "api"
},
{
"id": 4,
"name": "games/open",
"name": "games/notification",
"type": "api"
},
{
"id": 5,
"name": "games/ranking",
"name": "games/open",
"type": "api"
},
{
"id": 6,
"name": "gift/popup",
"name": "games/ranking",
"type": "api"
},
{
"id": 7,
"name": "gm/Pay",
"name": "gift/popup",
"type": "api"
},
{
"id": 8,
"name": "gm/SendPrize",
"name": "gm/Pay",
"type": "api"
},
{
"id": 9,
"name": "hdinfo/details",
"name": "gm/SendPrize",
"type": "api"
},
{
"id": 10,
"name": "AddHuoDong",
"name": "hdinfo/details",
"type": "api"
},
{
"id": 11,
"name": "CatAllhd",
"name": "AddHuoDong",
"type": "api"
},
{
"id": 12,
"name": "DelHuoDong",
"name": "CatAllhd",
"type": "api"
},
{
"id": 13,
"name": "Email",
"name": "DelHuoDong",
"type": "api"
},
{
"id": 14,
"name": "GetLog",
"name": "Email",
"type": "api"
},
{
"id": 15,
"name": "healthz",
"name": "GetLog",
"type": "api"
},
{
"id": 16,
"name": "union/rename",
"name": "healthz",
"type": "api"
},
{
"id": 17,
"name": "user/data",
"name": "union/rename",
"type": "api"
},
{
"id": 18,
"name": "user/disable",
"name": "user/data",
"type": "api"
},
{
"id": 19,
"name": "user/getdata",
"name": "user/disable",
"type": "api"
},
{
"id": 20,
"name": "user/getdata",
"type": "api"
},
{
"id": 21,
"name": "user/rename",
"type": "api"
}
@ -367,6 +377,44 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
]
},
"games/Ptlheapdump/Reqheapdump": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "act",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "data",
"type": {
"type": "Any"
}
}
]
},
"games/Ptlheapdump/Resheapdump": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "code",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "data",
"type": {
"type": "Any"
}
}
]
},
"games/Ptlmetrics/Reqmetrics": {
"type": "Interface"
},

View File

@ -10,7 +10,8 @@ export async function createHttp() {
json: true,
cors: '*',
port: G.config.httpPort,
logLevel: G.argv.logModel as LogLevel
logLevel: G.argv.logModel as LogLevel,
apiTimeout:300000,
});
setHttp(G.http);
await G.http.autoImplementApi(resolve(__dirname, 'api_o2s'), true);