File tree Expand file tree Collapse file tree 5 files changed +19
-5
lines changed
Expand file tree Collapse file tree 5 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -7,5 +7,7 @@ WORKDIR /cbsignal_uws
77COPY . /cbsignal_uws/
88RUN yarn install
99
10+ ENV NODE_OPTIONS="--expose-gc"
11+
1012CMD [ "node" , "index.js" , "config.yaml" ]
1113
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ const transportArr = [
1616 } )
1717] ;
1818
19+ const MEMORY_THRESHOLD = 0.90 ; // 90%
20+
1921let numCPUs = require ( "os" ) . availableParallelism ( ) ;
2022
2123const 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+
6172if ( 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 ) => {
Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff line change 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" ,
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"
You can’t perform that action at this time.
0 commit comments