Commit 057d656e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware: Don't start HTTP server if we specified no files

parent 1a5c9d30
...@@ -25,7 +25,9 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction ...@@ -25,7 +25,9 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
config := state["config"].(*config) config := state["config"].(*config)
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
httpPort := 8080 httpPort := 0
if config.HTTPDir != "" {
httpPort = 8080
httpAddr := fmt.Sprintf(":%d", httpPort) httpAddr := fmt.Sprintf(":%d", httpPort)
ui.Say(fmt.Sprintf("Starting HTTP server on port %d", httpPort)) ui.Say(fmt.Sprintf("Starting HTTP server on port %d", httpPort))
...@@ -42,6 +44,7 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction ...@@ -42,6 +44,7 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
fileServer := http.FileServer(http.Dir(config.HTTPDir)) fileServer := http.FileServer(http.Dir(config.HTTPDir))
server := &http.Server{Addr: httpAddr, Handler: fileServer} server := &http.Server{Addr: httpAddr, Handler: fileServer}
go server.Serve(s.l) go server.Serve(s.l)
}
// Save the address into the state so it can be accessed in the future // Save the address into the state so it can be accessed in the future
state["http_port"] = httpPort state["http_port"] = httpPort
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment