Update local runner lifecycle within client
This commit is contained in:
parent
572dcc8622
commit
cdfcd0dc5b
@ -13,6 +13,7 @@ import (
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||
configpkg "github.com/hashicorp/vagrant/internal/config"
|
||||
"github.com/hashicorp/vagrant/internal/runner"
|
||||
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
|
||||
"github.com/hashicorp/vagrant/internal/serverclient"
|
||||
)
|
||||
@ -36,6 +37,7 @@ type Basis struct {
|
||||
|
||||
local bool
|
||||
localServer bool // True when a local server is created
|
||||
localRunner *runner.Runner
|
||||
}
|
||||
|
||||
func New(ctx context.Context, opts ...Option) (basis *Basis, err error) {
|
||||
|
||||
@ -59,18 +59,27 @@ func (b *Basis) doJob(ctx context.Context, job *vagrant_server.Job, ui terminal.
|
||||
|
||||
// In local mode we have to start a runner.
|
||||
if b.local {
|
||||
log.Info("local mode, starting local runner")
|
||||
r, err := b.startRunner()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
if b.localRunner == nil {
|
||||
log.Info("local mode, starting local runner")
|
||||
r, err := b.startRunner()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b.localRunner = r
|
||||
b.cleanup(func() { r.Close() })
|
||||
}
|
||||
|
||||
log.Info("runner started", "runner_id", r.Id())
|
||||
r := b.localRunner
|
||||
|
||||
log.Info("using local runner", "runner_id", r.Id())
|
||||
|
||||
// We defer the close so that we clean up resources. Local mode
|
||||
// always blocks and streams the full output so when doJob exits
|
||||
// the job is complete.
|
||||
defer r.Close()
|
||||
|
||||
// defer r.Close()
|
||||
|
||||
var jobCh chan struct{}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user