Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
f765e82a
Commit
f765e82a
authored
9 years ago
by
Diptanu Choudhury
Browse files
Options
Download
Email Patches
Plain Diff
Stopping the metrics collector timers using defer and starting to collect host stats right away
parent
03c9d94a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/client.go
+4
-2
client/client.go
client/driver/executor/executor.go
+1
-1
client/driver/executor/executor.go
with
5 additions
and
3 deletions
+5
-3
client/client.go
+
4
-
2
View file @
f765e82a
...
...
@@ -1282,7 +1282,10 @@ func (c *Client) syncConsul() {
// collectHostStats collects host resource usage stats periodically
func
(
c
*
Client
)
collectHostStats
()
{
next
:=
time
.
NewTimer
(
c
.
config
.
StatsCollectionInterval
)
// Start collecting host stats right away and then keep collecting every
// collection interval
next
:=
time
.
NewTimer
(
0
)
defer
next
.
Stop
()
for
{
select
{
case
<-
next
.
C
:
...
...
@@ -1296,7 +1299,6 @@ func (c *Client) collectHostStats() {
c
.
resourceUsageLock
.
RUnlock
()
next
.
Reset
(
c
.
config
.
StatsCollectionInterval
)
case
<-
c
.
shutdownCh
:
next
.
Stop
()
return
}
}
...
...
This diff is collapsed.
Click to expand it.
client/driver/executor/executor.go
+
1
-
1
View file @
f765e82a
...
...
@@ -688,6 +688,7 @@ func (e *UniversalExecutor) collectPids() {
// Fire the timer right away when the executor starts from there on the pids
// are collected every scan interval
timer
:=
time
.
NewTimer
(
0
)
defer
timer
.
Stop
()
for
{
select
{
case
<-
timer
.
C
:
...
...
@@ -700,7 +701,6 @@ func (e *UniversalExecutor) collectPids() {
e
.
pidLock
.
Unlock
()
timer
.
Reset
(
pidScanInterval
)
case
<-
e
.
processExited
:
timer
.
Stop
()
return
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help