Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
a72bd5cf
Unverified
Commit
a72bd5cf
authored
5 years ago
by
Drew Bailey
Browse files
Options
Download
Email Patches
Plain Diff
use channel instead of empty string to determine close
parent
9bb606a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/agent.go
+5
-6
api/agent.go
command/agent_monitor.go
+2
-2
command/agent_monitor.go
with
7 additions
and
8 deletions
+7
-8
api/agent.go
+
5
-
6
View file @
a72bd5cf
...
...
@@ -255,26 +255,25 @@ func (a *Agent) Monitor(stopCh <-chan struct{}, q *QueryOptions) (chan string, e
logCh
:=
make
(
chan
string
,
64
)
go
func
()
{
defer
resp
.
Body
.
Close
()
defer
close
(
logCh
)
scanner
:=
bufio
.
NewScanner
(
resp
.
Body
)
LOOP
:
for
{
select
{
case
<-
stopCh
:
return
default
:
}
if
scanner
.
Scan
()
{
// An empty string signals to the caller that
// the scan is done, so make sure we only emit
// that when the scanner says it's done, not if
// we happen to ingest an empty line.
if
text
:=
scanner
.
Text
();
text
!=
""
{
logCh
<-
text
}
else
{
logCh
<-
" "
}
}
else
{
logCh
<-
""
break
LOOP
}
}
}()
...
...
This diff is collapsed.
Click to expand it.
command/agent_monitor.go
+
2
-
2
View file @
a72bd5cf
...
...
@@ -101,8 +101,8 @@ func (c *MonitorCommand) Run(args []string) int {
OUTER
:
for
{
select
{
case
log
:=
<-
logCh
:
if
log
==
""
{
case
log
,
ok
:=
<-
logCh
:
if
!
ok
{
break
OUTER
}
c
.
Ui
.
Output
(
log
)
...
...
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