2014-08-13 01:46:43 +08:00
|
|
|
package main
|
2014-06-05 07:46:30 +08:00
|
|
|
|
|
|
|
import (
|
2015-02-11 03:51:45 +08:00
|
|
|
"runtime"
|
2014-06-05 07:46:30 +08:00
|
|
|
|
2015-02-17 05:09:00 +08:00
|
|
|
log "github.com/Sirupsen/logrus"
|
2014-06-05 07:46:30 +08:00
|
|
|
"github.com/codegangsta/cli"
|
2014-12-15 23:08:56 +08:00
|
|
|
"github.com/docker/libcontainer"
|
2015-02-01 13:21:06 +08:00
|
|
|
_ "github.com/docker/libcontainer/nsenter"
|
2014-06-05 07:46:30 +08:00
|
|
|
)
|
|
|
|
|
2015-02-01 12:51:12 +08:00
|
|
|
var initCommand = cli.Command{
|
|
|
|
Name: "init",
|
|
|
|
Usage: "runs the init process inside the namespace",
|
|
|
|
Action: func(context *cli.Context) {
|
2015-02-17 05:09:00 +08:00
|
|
|
log.SetLevel(log.DebugLevel)
|
2015-02-11 03:51:45 +08:00
|
|
|
runtime.GOMAXPROCS(1)
|
|
|
|
runtime.LockOSThread()
|
2015-02-14 07:43:14 +08:00
|
|
|
factory, err := libcontainer.New("")
|
2015-02-01 12:51:12 +08:00
|
|
|
if err != nil {
|
2015-02-18 13:37:02 +08:00
|
|
|
fatal(err)
|
2015-02-01 12:51:12 +08:00
|
|
|
}
|
2015-02-12 08:45:23 +08:00
|
|
|
if err := factory.StartInitialization(3); err != nil {
|
2015-02-18 13:37:02 +08:00
|
|
|
fatal(err)
|
2015-02-01 12:51:12 +08:00
|
|
|
}
|
|
|
|
panic("This line should never been executed")
|
|
|
|
},
|
2014-06-05 07:46:30 +08:00
|
|
|
}
|