diff options
author | Alex Auvolat <alex@adnab.me> | 2022-11-28 12:37:50 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-11-28 12:37:50 +0100 |
commit | 77a2fb9190e1add91205d3bd26792fbbd8c0f459 (patch) | |
tree | 10b947f7f806247b4138878ae19e59f351ab9651 /exec2/driver.go | |
parent | 06be7dcbf6ad5a0a068d6478c98b17306af44394 (diff) | |
download | nomad-driver-nix2-77a2fb9190e1add91205d3bd26792fbbd8c0f459.tar.gz nomad-driver-nix2-77a2fb9190e1add91205d3bd26792fbbd8c0f459.zip |
First build as external plugin
Diffstat (limited to 'exec2/driver.go')
-rw-r--r-- | exec2/driver.go | 21 |
1 files changed, 10 insertions, 11 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, } } |