1package interfaces 2 3import ( 4 "context" 5 6 "github.com/hashicorp/nomad/nomad/structs" 7) 8 9type TaskLifecycle interface { 10 // Restart a task in place. If failure=false then the restart does not 11 // count as an attempt in the restart policy. 12 Restart(ctx context.Context, event *structs.TaskEvent, failure bool) error 13 14 // Sends a signal to a task. 15 Signal(event *structs.TaskEvent, signal string) error 16 17 // Kill a task permanently. 18 Kill(ctx context.Context, event *structs.TaskEvent) error 19 20 // IsRunning returns true if the task runner has a handle to the task 21 // driver, which is useful for distinguishing restored tasks during 22 // prestart hooks. But note that the driver handle could go away after you 23 // check this, so callers should make sure they're handling that case 24 // safely. Ideally prestart hooks should be idempotent whenever possible 25 // to handle restored tasks; use this as an escape hatch. 26 IsRunning() bool 27} 28