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
057d656e
Commit
057d656e
authored
Jun 06, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Don't start HTTP server if we specified no files
parent
1a5c9d30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
builder/vmware/step_http_server.go
builder/vmware/step_http_server.go
+19
-16
No files found.
builder/vmware/step_http_server.go
View file @
057d656e
...
...
@@ -25,24 +25,27 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
config
:=
state
[
"config"
]
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
httpPort
:=
8080
httpAddr
:=
fmt
.
Sprintf
(
":%d"
,
httpPort
)
ui
.
Say
(
fmt
.
Sprintf
(
"Starting HTTP server on port %d"
,
httpPort
))
// Start the TCP listener
var
err
error
s
.
l
,
err
=
net
.
Listen
(
"tcp"
,
httpAddr
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error starting HTTP server: %s"
,
err
))
return
multistep
.
ActionHalt
httpPort
:=
0
if
config
.
HTTPDir
!=
""
{
httpPort
=
8080
httpAddr
:=
fmt
.
Sprintf
(
":%d"
,
httpPort
)
ui
.
Say
(
fmt
.
Sprintf
(
"Starting HTTP server on port %d"
,
httpPort
))
// Start the TCP listener
var
err
error
s
.
l
,
err
=
net
.
Listen
(
"tcp"
,
httpAddr
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error starting HTTP server: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Start the HTTP server and run it in the background
fileServer
:=
http
.
FileServer
(
http
.
Dir
(
config
.
HTTPDir
))
server
:=
&
http
.
Server
{
Addr
:
httpAddr
,
Handler
:
fileServer
}
go
server
.
Serve
(
s
.
l
)
}
// Start the HTTP server and run it in the background
fileServer
:=
http
.
FileServer
(
http
.
Dir
(
config
.
HTTPDir
))
server
:=
&
http
.
Server
{
Addr
:
httpAddr
,
Handler
:
fileServer
}
go
server
.
Serve
(
s
.
l
)
// Save the address into the state so it can be accessed in the future
state
[
"http_port"
]
=
httpPort
...
...
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