Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Essem
Sharkey
Commits
0702d097
Unverified
Commit
0702d097
authored
6 years ago
by
syuilo
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2199 from syuilo/patch-2176
Resolve #2176
parents
dc02168f
f443d36d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/daemons/notes-stats.ts
+4
-3
4 additions, 3 deletions
src/daemons/notes-stats.ts
src/daemons/server-stats.ts
+4
-3
4 additions, 3 deletions
src/daemons/server-stats.ts
src/misc/queue.ts
+33
-0
33 additions, 0 deletions
src/misc/queue.ts
with
41 additions
and
6 deletions
src/daemons/notes-stats.ts
+
4
−
3
View file @
0702d097
import
*
as
childProcess
from
'
child_process
'
;
import
Xev
from
'
xev
'
;
import
Queue
from
'
../misc/queue
'
;
const
ev
=
new
Xev
();
export
default
function
()
{
const
log
:
any
[]
=
[]
;
const
log
=
new
Queue
<
any
>
()
;
const
p
=
childProcess
.
fork
(
__dirname
+
'
/notes-stats-child.js
'
);
p
.
on
(
'
message
'
,
stats
=>
{
ev
.
emit
(
'
notesStats
'
,
stats
);
log
.
push
(
stats
);
if
(
log
.
length
>
100
)
log
.
shift
();
if
(
log
.
length
>
100
)
log
.
pop
();
});
ev
.
on
(
'
requestNotesStatsLog
'
,
id
=>
{
ev
.
emit
(
'
notesStatsLog:
'
+
id
,
log
);
ev
.
emit
(
'
notesStatsLog:
'
+
id
,
log
.
toArray
()
);
});
process
.
on
(
'
exit
'
,
code
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/daemons/server-stats.ts
+
4
−
3
View file @
0702d097
...
...
@@ -2,6 +2,7 @@ import * as os from 'os';
import
*
as
sysUtils
from
'
systeminformation
'
;
import
*
as
diskusage
from
'
diskusage
'
;
import
Xev
from
'
xev
'
;
import
Queue
from
'
../misc/queue
'
;
const
osUtils
=
require
(
'
os-utils
'
);
const
ev
=
new
Xev
();
...
...
@@ -12,10 +13,10 @@ const interval = 1000;
* Report server stats regularly
*/
export
default
function
()
{
const
log
:
any
[]
=
[]
;
const
log
=
new
Queue
<
any
>
()
;
ev
.
on
(
'
requestServerStatsLog
'
,
id
=>
{
ev
.
emit
(
'
serverStatsLog:
'
+
id
,
log
);
ev
.
emit
(
'
serverStatsLog:
'
+
id
,
log
.
toArray
()
);
});
async
function
tick
()
{
...
...
@@ -36,7 +37,7 @@ export default function() {
};
ev
.
emit
(
'
serverStats
'
,
stats
);
log
.
push
(
stats
);
if
(
log
.
length
>
50
)
log
.
shift
();
if
(
log
.
length
>
50
)
log
.
pop
();
}
tick
();
...
...
This diff is collapsed.
Click to expand it.
src/misc/queue.ts
0 → 100644
+
33
−
0
View file @
0702d097
type
Node
<
T
>
=
{
value
:
T
,
next
:
Node
<
T
>
};
export
default
class
Queue
<
T
>
{
private
top
:
Node
<
T
>
=
null
;
private
rear
:
Node
<
T
>
=
null
;
public
length
:
number
=
0
;
public
push
(
value
:
T
):
void
{
const
node
:
Node
<
T
>
=
{
value
,
next
:
null
};
if
(
this
.
top
===
null
)
{
this
.
top
=
node
;
this
.
rear
=
node
;
}
else
{
this
.
rear
.
next
=
node
;
this
.
rear
=
node
;
}
this
.
length
++
;
}
public
pop
():
void
{
this
.
top
=
this
.
top
.
next
;
if
(
this
.
top
==
null
)
this
.
rear
=
null
;
this
.
length
--
;
}
public
toArray
():
T
[]
{
const
arr
:
T
[]
=
Array
<
T
>
(
this
.
length
);
for
(
let
node
=
this
.
top
,
i
=
0
;
node
!==
null
;
node
=
node
.
next
,
i
++
)
{
arr
[
i
]
=
node
.
value
;
}
return
arr
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment