2016-03-18 14:50:19 -04:00
|
|
|
package libcontainerd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-04-18 16:10:15 -04:00
|
|
|
"time"
|
2016-03-18 14:50:19 -04:00
|
|
|
|
|
|
|
"github.com/docker/docker/restartmanager"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// InitFriendlyName is the name given in the lookup map of processes
|
|
|
|
// for the first process started in a container.
|
|
|
|
InitFriendlyName = "init"
|
|
|
|
configFilename = "config.json"
|
|
|
|
)
|
|
|
|
|
|
|
|
type containerCommon struct {
|
|
|
|
process
|
|
|
|
restartManager restartmanager.RestartManager
|
|
|
|
restarting bool
|
|
|
|
processes map[string]*process
|
2016-04-18 16:10:15 -04:00
|
|
|
startedAt time.Time
|
2016-03-18 14:50:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// WithRestartManager sets the restartmanager to be used with the container.
|
|
|
|
func WithRestartManager(rm restartmanager.RestartManager) CreateOption {
|
|
|
|
return restartManager{rm}
|
|
|
|
}
|
|
|
|
|
|
|
|
type restartManager struct {
|
|
|
|
rm restartmanager.RestartManager
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rm restartManager) Apply(p interface{}) error {
|
|
|
|
if pr, ok := p.(*container); ok {
|
|
|
|
pr.restartManager = rm.rm
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("WithRestartManager option not supported for this client")
|
|
|
|
}
|