mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add json tags and comments to exedriver types
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
f3f2456b04
commit
e765c67b47
2 changed files with 28 additions and 28 deletions
|
@ -1,11 +1,17 @@
|
||||||
package execdriver
|
package execdriver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrNotRunning = errors.New("Process could not be started")
|
||||||
|
ErrWaitTimeoutReached = errors.New("Wait timeout reached")
|
||||||
|
)
|
||||||
|
|
||||||
type StartCallback func(*Process)
|
type StartCallback func(*Process)
|
||||||
|
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
|
@ -19,29 +25,31 @@ type Driver interface {
|
||||||
|
|
||||||
// Network settings of the container
|
// Network settings of the container
|
||||||
type Network struct {
|
type Network struct {
|
||||||
Gateway string
|
Gateway string `json:"gateway"`
|
||||||
IPAddress string
|
IPAddress string `json:"ip"`
|
||||||
IPPrefixLen int
|
IPPrefixLen int `json:"ip_prefix_len"`
|
||||||
Mtu int
|
Mtu int `json:"mtu"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process wrapps an os/exec.Cmd to add more metadata
|
// Process wrapps an os/exec.Cmd to add more metadata
|
||||||
type Process struct {
|
type Process struct {
|
||||||
exec.Cmd
|
exec.Cmd
|
||||||
|
|
||||||
ID string
|
ID string `json:"id"`
|
||||||
Privileged bool
|
Privileged bool `json:"privileged"`
|
||||||
User string
|
User string `json:"user"`
|
||||||
Rootfs string // root fs of the container
|
Rootfs string `json:"rootfs"` // root fs of the container
|
||||||
InitPath string // dockerinit
|
InitPath string `json:"initpath"` // dockerinit
|
||||||
Entrypoint string
|
Entrypoint string `json:"entrypoint"`
|
||||||
Arguments []string
|
Arguments []string `json:"arguments"`
|
||||||
WorkingDir string
|
WorkingDir string `json:"working_dir"`
|
||||||
ConfigPath string
|
ConfigPath string `json:"config_path"` // This should be able to be removed when the lxc template is moved into the driver
|
||||||
Tty bool
|
Tty bool `json:"tty"`
|
||||||
Network *Network // if network is nil then networking is disabled
|
Network *Network `json:"network"` // if network is nil then networking is disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the pid of the process
|
||||||
|
// If the process is nil -1 will be returned
|
||||||
func (c *Process) Pid() int {
|
func (c *Process) Pid() int {
|
||||||
if c.Process == nil {
|
if c.Process == nil {
|
||||||
return -1
|
return -1
|
||||||
|
@ -49,6 +57,8 @@ func (c *Process) Pid() int {
|
||||||
return c.Process.Pid
|
return c.Process.Pid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the exit code of the process
|
||||||
|
// if the process has not exited -1 will be returned
|
||||||
func (c *Process) GetExitCode() int {
|
func (c *Process) GetExitCode() int {
|
||||||
if c.ProcessState == nil {
|
if c.ProcessState == nil {
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package lxc
|
package lxc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/execdriver"
|
"github.com/dotcloud/docker/execdriver"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
|
@ -14,15 +13,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
startPath = "lxc-start"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrNotRunning = errors.New("Process could not be started")
|
|
||||||
ErrWaitTimeoutReached = errors.New("Wait timeout reached")
|
|
||||||
)
|
|
||||||
|
|
||||||
type driver struct {
|
type driver struct {
|
||||||
root string // root path for the driver to use
|
root string // root path for the driver to use
|
||||||
apparmor bool
|
apparmor bool
|
||||||
|
@ -47,7 +37,7 @@ func (d *driver) Name() string {
|
||||||
|
|
||||||
func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallback) (int, error) {
|
func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallback) (int, error) {
|
||||||
params := []string{
|
params := []string{
|
||||||
startPath,
|
"lxc-start",
|
||||||
"-n", c.ID,
|
"-n", c.ID,
|
||||||
"-f", c.ConfigPath,
|
"-f", c.ConfigPath,
|
||||||
"--",
|
"--",
|
||||||
|
@ -155,7 +145,7 @@ func (d *driver) Wait(id string, duration time.Duration) error {
|
||||||
return err
|
return err
|
||||||
case <-time.After(duration):
|
case <-time.After(duration):
|
||||||
killer = true
|
killer = true
|
||||||
return ErrWaitTimeoutReached
|
return execdriver.ErrWaitTimeoutReached
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return <-done
|
return <-done
|
||||||
|
@ -214,7 +204,7 @@ func (d *driver) waitForStart(c *execdriver.Process, waitLock chan struct{}) err
|
||||||
}
|
}
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
}
|
}
|
||||||
return ErrNotRunning
|
return execdriver.ErrNotRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) waitLxc(id string, kill *bool) <-chan error {
|
func (d *driver) waitLxc(id string, kill *bool) <-chan error {
|
||||||
|
|
Loading…
Add table
Reference in a new issue