Skip to content

Commit c27e7aa

Browse files
committed
5.5.3
1 parent 83cb743 commit c27e7aa

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

.github/workflows/docker-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ jobs:
3535
with:
3636
push: true
3737
platforms: linux/amd64
38-
tags: cdnbye/cbsignal_uws:latest
39-
# tags: cdnbye/cbsignal_uws:5.5.2
38+
# tags: cdnbye/cbsignal_uws:latest
39+
tags: cdnbye/cbsignal_uws:5.5.3

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ WORKDIR /cbsignal_uws
77
COPY . /cbsignal_uws/
88
RUN yarn install
99

10+
ENV NODE_OPTIONS="--expose-gc"
11+
1012
CMD [ "node", "index.js", "config.yaml"]
1113

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const transportArr = [
1616
})
1717
];
1818

19+
const MEMORY_THRESHOLD = 0.90; // 90%
20+
1921
let numCPUs = require("os").availableParallelism();
2022

2123
const program = new Command();
@@ -58,6 +60,15 @@ const logger = createLogger({
5860
transports: transportArr,
5961
});
6062

63+
setInterval(() => {
64+
const { heapUsed, heapTotal } = process.memoryUsage();
65+
const ratio = heapUsed / heapTotal;
66+
if (ratio > MEMORY_THRESHOLD) {
67+
logger.warn(`Memory usage high: ${(ratio * 100).toFixed(2)}%,gc`);
68+
if (global.gc) global.gc();
69+
}
70+
}, 30000);
71+
6172
if (cluster.isPrimary) {
6273
masterProc();
6374
} else {
@@ -145,6 +156,7 @@ function setupWorker(worker) {
145156
}
146157
}, 5000);
147158
worker.on('exit', (code, signal) => {
159+
logger.error(`worker exit, code ${code} signal ${signal}`)
148160
clearInterval(timer);
149161
})
150162
worker.on('message', (msg) => {

lib/broker/redis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function initCache(max = 100000) {
158158
// },
159159

160160
// how long to live in ms
161-
ttl: 1000 * 60 * 10,
161+
ttl: 1000 * 60 * 15,
162162

163163
// return stale items before removing from cache?
164164
allowStale: false,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cbsignal_uws",
3-
"version": "5.5.2",
3+
"version": "5.5.3",
44
"description": "SwarmCloud signaling server using uWebSockets.js",
55
"main": "index.js",
66
"bin": "index.js",
@@ -38,7 +38,7 @@
3838
"lodash": "^4.17.21",
3939
"lru-cache": "^10.0.1",
4040
"protobufjs": "^7.2.5",
41-
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.52.0",
41+
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.56.0",
4242
"winston": "^3.8.2",
4343
"winston-daily-rotate-file": "^4.7.1",
4444
"yamljs": "^0.3.0"

0 commit comments

Comments
 (0)