packer/rpc: less panics
This commit is contained in:
parent
043264ca77
commit
df70443a7c
|
@ -61,20 +61,20 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
go func() {
|
go func() {
|
||||||
defer responseL.Close()
|
defer responseL.Close()
|
||||||
|
|
||||||
|
var response BuilderRunResponse
|
||||||
|
defer func() { runResponseCh <- &response }()
|
||||||
|
|
||||||
conn, err := responseL.Accept()
|
conn, err := responseL.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
response.Err = err
|
||||||
|
return
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
decoder := gob.NewDecoder(conn)
|
decoder := gob.NewDecoder(conn)
|
||||||
|
|
||||||
var response BuilderRunResponse
|
|
||||||
if err := decoder.Decode(&response); err != nil {
|
if err := decoder.Decode(&response); err != nil {
|
||||||
response.Err = fmt.Errorf("Error waiting for Run: %s", err)
|
response.Err = fmt.Errorf("Error waiting for Run: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
runResponseCh <- &response
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
args := &BuilderRunArgs{
|
args := &BuilderRunArgs{
|
||||||
|
@ -154,7 +154,7 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error {
|
||||||
|
|
||||||
err := responseWriter.Encode(&BuilderRunResponse{responseErr, responseAddress})
|
err := responseWriter.Encode(&BuilderRunResponse{responseErr, responseAddress})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Printf("BuildServer.Run error: %s", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue