0ba1a5251b
Some of the context uses in TR hooks are useless (Killed during Stop never seems meaningful). None of the hooks are interruptable for graceful shutdown which is unfortunate and probably needs fixing.
34 lines
684 B
Go
34 lines
684 B
Go
package allocrunner
|
|
|
|
import (
|
|
log "github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/nomad/client/allocdir"
|
|
)
|
|
|
|
// allocDirHook creates and destroys the root directory and shared directories
|
|
// for an allocation.
|
|
type allocDirHook struct {
|
|
allocDir *allocdir.AllocDir
|
|
logger log.Logger
|
|
}
|
|
|
|
func newAllocDirHook(logger log.Logger, allocDir *allocdir.AllocDir) *allocDirHook {
|
|
ad := &allocDirHook{
|
|
allocDir: allocDir,
|
|
}
|
|
ad.logger = logger.Named(ad.Name())
|
|
return ad
|
|
}
|
|
|
|
func (h *allocDirHook) Name() string {
|
|
return "alloc_dir"
|
|
}
|
|
|
|
func (h *allocDirHook) Prerun() error {
|
|
return h.allocDir.Build()
|
|
}
|
|
|
|
func (h *allocDirHook) Destroy() error {
|
|
return h.allocDir.Destroy()
|
|
}
|