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
256b97ce
Commit
256b97ce
authored
Jun 03, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Signal handling, force quit after two interrupts
parent
5c39a2f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
packer.go
packer.go
+2
-0
signal.go
signal.go
+29
-0
No files found.
packer.go
View file @
256b97ce
...
...
@@ -96,6 +96,8 @@ func main() {
os
.
Exit
(
1
)
}
setupSignalHandlers
(
env
)
exitCode
,
err
:=
env
.
Cli
(
os
.
Args
[
1
:
])
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error executing CLI: %s
\n
"
,
err
.
Error
())
...
...
signal.go
0 → 100644
View file @
256b97ce
package
main
import
(
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer/plugin"
"log"
"os"
"os/signal"
)
// Prepares the signal handlers so that we handle interrupts properly.
// The signal handler exists in a goroutine.
func
setupSignalHandlers
(
env
packer
.
Environment
)
{
ch
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
ch
,
os
.
Interrupt
)
go
func
()
{
<-
ch
log
.
Println
(
"First interrupt. Ignoring, will let plugins handle..."
)
<-
ch
log
.
Println
(
"Second interrupt. Exiting now."
)
env
.
Ui
()
.
Error
(
"Interrupt signal received twice. Forcefully exiting now."
)
// Force kill all the plugins
plugin
.
CleanupClients
()
os
.
Exit
(
1
)
}()
}
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