Update packer.go to cleanup plugin clients on exit.

Since defer does not fire when exiting the application with os.Exit we need to be sure that we cleanup all of the clients on failures from the CLI and creating a new environment object.
This commit is contained in:
John Bellone 2013-08-08 12:16:28 -04:00
parent 9638a30d35
commit 1519341cb1
1 changed files with 2 additions and 0 deletions

View File

@ -90,6 +90,7 @@ func main() {
env, err := packer.NewEnvironment(envConfig)
if err != nil {
fmt.Fprintf(os.Stderr, "Packer initialization error: \n\n%s\n", err)
plugin.CleanupClients()
os.Exit(1)
}
@ -98,6 +99,7 @@ func main() {
exitCode, err := env.Cli(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
plugin.CleanupClients()
os.Exit(1)
}