mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-08 15:01:42 +00:00
Rename Process to Command
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
@@ -36,7 +36,7 @@ func NewDriver() (*driver, error) {
|
||||
return &driver{}, nil
|
||||
}
|
||||
|
||||
func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallback) (int, error) {
|
||||
func (d *driver) Run(c *execdriver.Command, startCallback execdriver.StartCallback) (int, error) {
|
||||
params := []string{
|
||||
"chroot",
|
||||
c.Rootfs,
|
||||
@@ -70,7 +70,7 @@ func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallba
|
||||
return c.GetExitCode(), err
|
||||
}
|
||||
|
||||
func (d *driver) Kill(p *execdriver.Process, sig int) error {
|
||||
func (d *driver) Kill(p *execdriver.Command, sig int) error {
|
||||
return p.Process.Kill()
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ var (
|
||||
var dockerInitFcts map[string]InitFunc
|
||||
|
||||
type (
|
||||
StartCallback func(*Process)
|
||||
StartCallback func(*Command)
|
||||
InitFunc func(i *InitArgs) error
|
||||
)
|
||||
|
||||
@@ -59,8 +59,8 @@ type Info interface {
|
||||
}
|
||||
|
||||
type Driver interface {
|
||||
Run(c *Process, startCallback StartCallback) (int, error) // Run executes the process and blocks until the process exits and returns the exit code
|
||||
Kill(c *Process, sig int) error
|
||||
Run(c *Command, startCallback StartCallback) (int, error) // Run executes the process and blocks until the process exits and returns the exit code
|
||||
Kill(c *Command, sig int) error
|
||||
Wait(id string) error // Wait on an out of process...process - lxc ghosts TODO: Rename to reattach, reconnect
|
||||
Name() string // Driver name
|
||||
Info(id string) Info // "temporary" hack (until we move state from core to plugins)
|
||||
@@ -83,8 +83,8 @@ type Resources struct {
|
||||
|
||||
// Process wrapps an os/exec.Cmd to add more metadata
|
||||
// TODO: Rename to Command
|
||||
type Process struct {
|
||||
exec.Cmd
|
||||
type Command struct {
|
||||
exec.Cmd `json:"-"`
|
||||
|
||||
ID string `json:"id"`
|
||||
Privileged bool `json:"privileged"`
|
||||
@@ -103,7 +103,7 @@ type Process struct {
|
||||
|
||||
// Return the pid of the process
|
||||
// If the process is nil -1 will be returned
|
||||
func (c *Process) Pid() int {
|
||||
func (c *Command) Pid() int {
|
||||
if c.Process == nil {
|
||||
return -1
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (c *Process) Pid() int {
|
||||
|
||||
// Return the exit code of the process
|
||||
// if the process has not exited -1 will be returned
|
||||
func (c *Process) GetExitCode() int {
|
||||
func (c *Command) GetExitCode() int {
|
||||
if c.ProcessState == nil {
|
||||
return -1
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ func init() {
|
||||
if err := setupCapabilities(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := setupWorkingDirectory(args); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -37,6 +38,7 @@ func init() {
|
||||
if err := changeUser(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path, err := exec.LookPath(args.Args[0])
|
||||
if err != nil {
|
||||
log.Printf("Unable to locate %v", args.Args[0])
|
||||
@@ -72,7 +74,7 @@ func (d *driver) Name() string {
|
||||
return fmt.Sprintf("%s-%s", DriverName, version)
|
||||
}
|
||||
|
||||
func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallback) (int, error) {
|
||||
func (d *driver) Run(c *execdriver.Command, startCallback execdriver.StartCallback) (int, error) {
|
||||
configPath, err := d.generateLXCConfig(c)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
@@ -170,7 +172,7 @@ func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallba
|
||||
return c.GetExitCode(), waitErr
|
||||
}
|
||||
|
||||
func (d *driver) Kill(c *execdriver.Process, sig int) error {
|
||||
func (d *driver) Kill(c *execdriver.Command, sig int) error {
|
||||
return d.kill(c, sig)
|
||||
}
|
||||
|
||||
@@ -198,7 +200,7 @@ func (d *driver) version() string {
|
||||
return version
|
||||
}
|
||||
|
||||
func (d *driver) kill(c *execdriver.Process, sig int) error {
|
||||
func (d *driver) kill(c *execdriver.Command, sig int) error {
|
||||
output, err := exec.Command("lxc-kill", "-n", c.ID, strconv.Itoa(sig)).CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Err: %s Output: %s", err, output)
|
||||
@@ -206,7 +208,7 @@ func (d *driver) kill(c *execdriver.Process, sig int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *driver) waitForStart(c *execdriver.Process, waitLock chan struct{}) error {
|
||||
func (d *driver) waitForStart(c *execdriver.Command, waitLock chan struct{}) error {
|
||||
var (
|
||||
err error
|
||||
output []byte
|
||||
@@ -302,8 +304,8 @@ func rootIsShared() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *driver) generateLXCConfig(p *execdriver.Process) (string, error) {
|
||||
root := path.Join(d.root, "containers", p.ID, "config.lxc")
|
||||
func (d *driver) generateLXCConfig(c *execdriver.Command) (string, error) {
|
||||
root := path.Join(d.root, "containers", c.ID, "config.lxc")
|
||||
fo, err := os.Create(root)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -311,10 +313,10 @@ func (d *driver) generateLXCConfig(p *execdriver.Process) (string, error) {
|
||||
defer fo.Close()
|
||||
|
||||
if err := LxcTemplateCompiled.Execute(fo, struct {
|
||||
*execdriver.Process
|
||||
*execdriver.Command
|
||||
AppArmor bool
|
||||
}{
|
||||
Process: p,
|
||||
Command: c,
|
||||
AppArmor: d.apparmor,
|
||||
}); err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -37,14 +37,14 @@ func TestLXCConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
process := &execdriver.Process{
|
||||
command := &execdriver.Command{
|
||||
ID: "1",
|
||||
Resources: &execdriver.Resources{
|
||||
Memory: int64(mem),
|
||||
CpuShares: int64(cpu),
|
||||
},
|
||||
}
|
||||
p, err := driver.generateLXCConfig(process)
|
||||
p, err := driver.generateLXCConfig(command)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func TestCustomLxcConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
process := &execdriver.Process{
|
||||
command := &execdriver.Command{
|
||||
ID: "1",
|
||||
Privileged: false,
|
||||
Config: []string{
|
||||
@@ -77,7 +77,7 @@ func TestCustomLxcConfig(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
p, err := driver.generateLXCConfig(process)
|
||||
p, err := driver.generateLXCConfig(command)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user