Documentation ¶
Overview ¶
Package deamon provides pre-forked container to reduce the container create / destroy costs (about 160ms). It creates deamon within unshared container and communicate with original process using unix socket with oob for fd / pid and structs are encoded in gob format.
Index ¶
- Variables
- func ContainerInit() (err error)
- func GetBuffer() []byte
- func PutBuffer(x []byte)
- type Cmd
- type ExecveParam
- type Master
- func (m *Master) CopyIn(f *os.File, p string) error
- func (m *Master) Delete(p string) error
- func (m *Master) Destroy() error
- func (m *Master) Execve(done <-chan struct{}, param *ExecveParam) (<-chan specs.TraceResult, error)
- func (m *Master) Open(p string) (*os.File, error)
- func (m *Master) Ping() error
- func (m *Master) Reset() error
- type Reply
Constants ¶
This section is empty.
Variables ¶
var ( DefaultPath = "PATH=/usr/local/bin:/usr/bin:/bin" // rootfs created by bind mounting DefaultMounts = []*mount.Mount{ { Source: "/usr", Target: "usr", Flags: roBind, }, { Source: "/lib", Target: "lib", Flags: roBind, }, { Source: "/lib64", Target: "lib64", Flags: roBind, }, { Source: "/bin", Target: "bin", Flags: roBind, }, { Source: "tmpfs", Target: "w", FsType: "tmpfs", Flags: mFlag, }, { Source: "tmpfs", Target: "tmp", FsType: "tmpfs", Flags: mFlag, }, } )
default parameters. I was tend to reuse the configs but it is hard since there are some cross device symblics
Functions ¶
func ContainerInit ¶
func ContainerInit() (err error)
ContainerInit is called for container init process it will check if pid == 1, otherwise it is noop ContainerInit will do infinite loop on socket commands, and exits when at socket close
Types ¶
type Cmd ¶
type Cmd struct { Cmd string // type of the cmd Path string // path (copyin / open) Argv []string // execve argv Envv []string // execve envv RLmits []rlimit.RLimit // execve posix rlimit FdExec bool // if use fexecve (fd[0] as exec) }
Cmd is the control message send into deamon
type ExecveParam ¶
type ExecveParam struct { Args []string Envv []string Fds []uintptr // fexecve fd ExecFile uintptr // POSIX Resource limit set by set rlimit RLimits []rlimit.RLimit // SyncFunc called with pid before execve SyncFunc func(pid int) error }
ExecveParam is parameters to run process inside container
type Master ¶
type Master struct {
// contains filtered or unexported fields
}
Master manages single pre-forked container
func (*Master) Execve ¶
func (m *Master) Execve(done <-chan struct{}, param *ExecveParam) (<-chan specs.TraceResult, error)
Execve runs process inside container accepts done for cancelation