aboutsummaryrefslogtreecommitdiff
path: root/exec2/handle.go
diff options
context:
space:
mode:
Diffstat (limited to 'exec2/handle.go')
-rw-r--r--exec2/handle.go35
1 files changed, 17 insertions, 18 deletions
diff --git a/exec2/handle.go b/exec2/handle.go
index 6dfb976..606406b 100644
--- a/exec2/handle.go
+++ b/exec2/handle.go
@@ -1,4 +1,4 @@
-package hello
+package exec
import (
"context"
@@ -6,30 +6,26 @@ import (
"sync"
"time"
- "github.com/hashicorp/go-hclog"
- "github.com/hashicorp/go-plugin"
+ hclog "github.com/hashicorp/go-hclog"
+ plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/plugins/drivers"
)
-// taskHandle should store all relevant runtime information
-// such as process ID if this is a local task or other meta
-// data if this driver deals with external APIs
type taskHandle struct {
- // stateLock syncs access to all fields below
- stateLock sync.RWMutex
-
- logger hclog.Logger
exec executor.Executor
+ pid int
pluginClient *plugin.Client
- taskConfig *drivers.TaskConfig
- procState drivers.TaskState
- startedAt time.Time
- completedAt time.Time
- exitResult *drivers.ExitResult
+ logger hclog.Logger
- // TODO: add any extra relevant information about the task.
- pid int
+ // stateLock syncs access to all fields below
+ stateLock sync.RWMutex
+
+ taskConfig *drivers.TaskConfig
+ procState drivers.TaskState
+ startedAt time.Time
+ completedAt time.Time
+ exitResult *drivers.ExitResult
}
func (h *taskHandle) TaskStatus() *drivers.TaskStatus {
@@ -62,8 +58,9 @@ func (h *taskHandle) run() {
}
h.stateLock.Unlock()
- // TODO: wait for your task to complete and upate its state.
+ // Block until process exits
ps, err := h.exec.Wait(context.Background())
+
h.stateLock.Lock()
defer h.stateLock.Unlock()
@@ -77,4 +74,6 @@ func (h *taskHandle) run() {
h.exitResult.ExitCode = ps.ExitCode
h.exitResult.Signal = ps.Signal
h.completedAt = ps.Time
+
+ // TODO: detect if the task OOMed
}