(ctx devspacecontext.Context, args []string, environ expand.Environ)
| 60 | } |
| 61 | |
| 62 | func (j *Job) Run(ctx devspacecontext.Context, args []string, environ expand.Environ) error { |
| 63 | if ctx.IsDone() { |
| 64 | return ctx.Context().Err() |
| 65 | } |
| 66 | |
| 67 | j.m.Lock() |
| 68 | ctx = ctx.WithContext(j.t.Context(ctx.Context())) |
| 69 | t := j.t |
| 70 | j.m.Unlock() |
| 71 | |
| 72 | t.Go(func() error { |
| 73 | // start the actual job |
| 74 | done := t.NotifyGo(func() error { |
| 75 | return j.execute(ctx, args, t, environ) |
| 76 | }) |
| 77 | |
| 78 | // wait until job is dying |
| 79 | select { |
| 80 | case <-ctx.Context().Done(): |
| 81 | return nil |
| 82 | case <-done: |
| 83 | } |
| 84 | |
| 85 | // check if errored |
| 86 | if !t.Alive() { |
| 87 | return t.Err() |
| 88 | } |
| 89 | |
| 90 | return nil |
| 91 | }) |
| 92 | |
| 93 | return t.Wait() |
| 94 | } |
| 95 | |
| 96 | func (j *Job) execute(ctx devspacecontext.Context, args []string, parent *tomb.Tomb, environ expand.Environ) error { |
| 97 | ctx = ctx.WithLogger(ctx.Log()) |
nothing calls this directly
no test coverage detected