Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
2ff1fabb
Commit
2ff1fabb
authored
May 07, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/plugin: timeout when starting a plugin
parent
c9c294f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
packer/plugin/command.go
packer/plugin/command.go
+7
-0
packer/plugin/command_test.go
packer/plugin/command_test.go
+2
-0
No files found.
packer/plugin/command.go
View file @
2ff1fabb
...
@@ -25,18 +25,25 @@ func Command(cmd *exec.Cmd) (result packer.Command, err error) {
...
@@ -25,18 +25,25 @@ func Command(cmd *exec.Cmd) (result packer.Command, err error) {
return
return
}
}
// Goroutine + channel to signal that the process exited
cmdExited
:=
make
(
chan
bool
)
cmdExited
:=
make
(
chan
bool
)
go
func
()
{
go
func
()
{
cmd
.
Wait
()
cmd
.
Wait
()
cmdExited
<-
true
cmdExited
<-
true
}()
}()
// Timer for a timeout
cmdTimeout
:=
time
.
After
(
1
*
time
.
Minute
)
var
address
string
var
address
string
for
done
:=
false
;
!
done
;
{
for
done
:=
false
;
!
done
;
{
select
{
select
{
case
<-
cmdExited
:
case
<-
cmdExited
:
err
=
errors
.
New
(
"plugin exited before we could connect"
)
err
=
errors
.
New
(
"plugin exited before we could connect"
)
done
=
true
done
=
true
case
<-
cmdTimeout
:
err
=
errors
.
New
(
"timeout while waiting for plugin to start"
)
done
=
true
default
:
default
:
}
}
...
...
packer/plugin/command_test.go
View file @
2ff1fabb
...
@@ -6,6 +6,8 @@ import (
...
@@ -6,6 +6,8 @@ import (
"testing"
"testing"
)
)
// TODO: Test timeout functionality
func
TestCommand_NoExist
(
t
*
testing
.
T
)
{
func
TestCommand_NoExist
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
...
...
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