diff options
Diffstat (limited to 'exec2')
-rw-r--r-- | exec2/driver.go | 21 | ||||
-rw-r--r-- | exec2/handle.go | 2 | ||||
-rw-r--r-- | exec2/state.go | 2 |
3 files changed, 12 insertions, 13 deletions
diff --git a/exec2/driver.go b/exec2/driver.go index f035d15..4e52062 100644 --- a/exec2/driver.go +++ b/exec2/driver.go @@ -1,4 +1,4 @@ -package exec +package exec2 import ( "context" @@ -27,7 +27,7 @@ import ( const ( // pluginName is the name of the plugin - pluginName = "exec" + pluginName = "exec2" // fingerprintPeriod is the interval at which the driver will send fingerprint responses fingerprintPeriod = 30 * time.Second @@ -45,13 +45,6 @@ var ( PluginType: base.PluginTypeDriver, } - // PluginConfig is the exec driver factory function registered in the - // plugin catalog. - PluginConfig = &loader.InternalPluginConfig{ - Config: map[string]interface{}{}, - Factory: func(ctx context.Context, l hclog.Logger) interface{} { return NewExecDriver(ctx, l) }, - } - // pluginInfo is the response returned for the PluginInfo RPC pluginInfo = &base.PluginInfoResponse{ Type: base.PluginTypeDriver, @@ -125,6 +118,10 @@ type Driver struct { // coordinate shutdown ctx context.Context + // signalShutdown is called when the driver is shutting down and cancels + // the ctx passed to any subsystems + signalShutdown context.CancelFunc + // logger will log to the Nomad agent logger hclog.Logger @@ -233,13 +230,15 @@ type TaskState struct { StartedAt time.Time } -// NewExecDriver returns a new DrivePlugin implementation -func NewExecDriver(ctx context.Context, logger hclog.Logger) drivers.DriverPlugin { +// NewPlugin returns a new DrivePlugin implementation +func NewPlugin(logger hclog.Logger) drivers.DriverPlugin { + ctx, cancel := context.WithCancel(context.Background()) logger = logger.Named(pluginName) return &Driver{ eventer: eventer.NewEventer(ctx, logger), tasks: newTaskStore(), ctx: ctx, + signalShutdown: cancel, logger: logger, } } diff --git a/exec2/handle.go b/exec2/handle.go index 606406b..1316922 100644 --- a/exec2/handle.go +++ b/exec2/handle.go @@ -1,4 +1,4 @@ -package exec +package exec2 import ( "context" diff --git a/exec2/state.go b/exec2/state.go index 08cdee8..277e336 100644 --- a/exec2/state.go +++ b/exec2/state.go @@ -1,4 +1,4 @@ -package exec +package exec2 import ( "sync" |