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
3956b3a5
Commit
3956b3a5
authored
Jun 03, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/build: Cancel builds when interrupted
parent
94cfe39a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
command/build/command.go
command/build/command.go
+25
-0
No files found.
command/build/command.go
View file @
3956b3a5
...
...
@@ -5,6 +5,8 @@ import (
"github.com/mitchellh/packer/packer"
"io/ioutil"
"log"
"os"
"os/signal"
"strings"
"sync"
)
...
...
@@ -112,6 +114,29 @@ func (c Command) Run(env packer.Environment, args []string) int {
}()
}
// Handle signals
sigCh
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
sigCh
,
os
.
Interrupt
)
go
func
()
{
<-
sigCh
log
.
Println
(
"Interrupted! Cancelling builds..."
)
var
wg
sync
.
WaitGroup
for
_
,
b
:=
range
builds
{
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
log
.
Printf
(
"Stopping build: %s"
,
b
.
Name
())
b
.
Cancel
()
}()
}
wg
.
Wait
()
}()
wg
.
Wait
()
// Output all the artifacts
...
...
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