diff --git a/packer/rpc/builder.go b/packer/rpc/builder.go index b6b46acb5..1c35e7ed7 100644 --- a/packer/rpc/builder.go +++ b/packer/rpc/builder.go @@ -93,7 +93,9 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact { } func (b *builder) Cancel() { - + if err := b.client.Call("Builder.Cancel", new(interface{}), new(interface{})); err != nil { + panic(err) + } } func (b *BuilderServer) Prepare(args *BuilderPrepareArgs, reply *error) error { @@ -135,3 +137,8 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error { return nil } + +func (b *BuilderServer) Cancel(args *interface{}, reply*interface{}) error { + b.builder.Cancel() + return nil +} diff --git a/packer/rpc/builder_test.go b/packer/rpc/builder_test.go index 790161acf..a17f0c229 100644 --- a/packer/rpc/builder_test.go +++ b/packer/rpc/builder_test.go @@ -73,6 +73,10 @@ func TestBuilderRPC(t *testing.T) { assert.Equal(artifact.Id(), testBuilderArtifact.Id(), "should have artifact Id") } + + // Test Cancel + bClient.Cancel() + assert.True(b.cancelCalled, "cancel should be called") } func TestBuilder_ImplementsBuilder(t *testing.T) { diff --git a/packer/rpc/server.go b/packer/rpc/server.go index 9a1037b74..6767b858d 100644 --- a/packer/rpc/server.go +++ b/packer/rpc/server.go @@ -66,7 +66,7 @@ func serveSingleConn(s *rpc.Server) string { defer l.Close() conn, err := l.Accept() if err != nil { - return + panic(err) } s.ServeConn(conn)