Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
srvpro
Commits
8de92df4
Commit
8de92df4
authored
Dec 24, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix memory usage
parent
4410b1e1
Pipeline
#1944
passed with stages
in 11 minutes and 19 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
+18
-5
package-lock.json
package-lock.json
+5
-0
package.json
package.json
+1
-0
ygopro-server.coffee
ygopro-server.coffee
+4
-1
ygopro-server.js
ygopro-server.js
+8
-4
No files found.
package-lock.json
View file @
8de92df4
...
...
@@ -1210,6 +1210,11 @@
}
}
},
"node-os-utils"
:
{
"version"
:
"1.3.2"
,
"resolved"
:
"https://registry.npmjs.org/node-os-utils/-/node-os-utils-1.3.2.tgz"
,
"integrity"
:
"sha512-wUo/q6u77y9+DBaXkn57IDyJlQuN7xP6VU9h6yeIGhKocc9rDQPyc3WmLgX+x5jf4WmbLcEaA3raM05+v5jW3g=="
},
"node-pre-gyp"
:
{
"version"
:
"0.11.0"
,
"resolved"
:
"https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz"
,
...
...
package.json
View file @
8de92df4
...
...
@@ -27,6 +27,7 @@
"
lzma
"
:
"
^2.3.2
"
,
"
moment
"
:
"
^2.29.1
"
,
"
mysql
"
:
"
^2.18.1
"
,
"
node-os-utils
"
:
"
^1.3.2
"
,
"
pg
"
:
"
^6.4.2
"
,
"
q
"
:
"
^1.5.1
"
,
"
querystring
"
:
"
^0.2.0
"
,
...
...
ygopro-server.coffee
View file @
8de92df4
...
...
@@ -22,6 +22,7 @@ axios = require 'axios'
qs
=
require
"querystring"
zlib
=
require
'zlib'
axios
=
require
'axios'
osu
=
require
'node-os-utils'
bunyan
=
require
'bunyan'
log
=
global
.
log
=
bunyan
.
createLogger
name
:
"mycard"
...
...
@@ -611,7 +612,9 @@ init = () ->
# 获取可用内存
memory_usage
=
global
.
memory_usage
=
0
get_memory_usage
=
global
.
get_memory_usage
=
()
->
percentUsed
=
(
1
-
os
.
freemem
()
/
os
.
totalmem
())
*
100
memoryInfo
=
await
osu
.
mem
.
info
()
percentUsed
=
100
-
memoryInfo
.
freeMemPercentage
# console.log(percentUsed)
memory_usage
=
global
.
memory_usage
=
percentUsed
return
get_memory_usage
()
...
...
ygopro-server.js
View file @
8de92df4
// Generated by CoffeeScript 2.5.1
(
function
()
{
// 标准库
var
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
_
,
_async
,
addCallback
,
athleticChecker
,
auth
,
axios
,
badwords
,
ban_user
,
bunyan
,
challonge
,
challonge_cache
,
challonge_queue_callbacks
,
checkFileExists
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
fs
,
geoip
,
getDuelLogQueryFromQs
,
getSeedTimet
,
get_callback
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
is_challonge_requesting
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_tips
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
net
,
netRequestHandler
,
os
,
path
,
qs
,
real_windbot_server_ip
,
refresh_challonge_cache
,
release_disconnect
,
replaced_index
,
report_to_big_brother
,
request
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
url
,
users_cache
,
util
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
var
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
_
,
_async
,
addCallback
,
athleticChecker
,
auth
,
axios
,
badwords
,
ban_user
,
bunyan
,
challonge
,
challonge_cache
,
challonge_queue_callbacks
,
checkFileExists
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
fs
,
geoip
,
getDuelLogQueryFromQs
,
getSeedTimet
,
get_callback
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
is_challonge_requesting
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_tips
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
net
,
netRequestHandler
,
os
,
osu
,
path
,
qs
,
real_windbot_server_ip
,
refresh_challonge_cache
,
release_disconnect
,
replaced_index
,
report_to_big_brother
,
request
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
url
,
users_cache
,
util
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -44,6 +44,8 @@
axios
=
require
(
'
axios
'
);
osu
=
require
(
'
node-os-utils
'
);
bunyan
=
require
(
'
bunyan
'
);
log
=
global
.
log
=
bunyan
.
createLogger
({
...
...
@@ -777,9 +779,11 @@
// 获取可用内存
memory_usage
=
global
.
memory_usage
=
0
;
get_memory_usage
=
global
.
get_memory_usage
=
function
()
{
var
percentUsed
;
percentUsed
=
(
1
-
os
.
freemem
()
/
os
.
totalmem
())
*
100
;
get_memory_usage
=
global
.
get_memory_usage
=
async
function
()
{
var
memoryInfo
,
percentUsed
;
memoryInfo
=
(
await
osu
.
mem
.
info
());
percentUsed
=
100
-
memoryInfo
.
freeMemPercentage
;
console
.
log
(
percentUsed
);
memory_usage
=
global
.
memory_usage
=
percentUsed
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment