diff --git a/init.go b/init.go index 59ce1e8c7..d39492952 100644 --- a/init.go +++ b/init.go @@ -10,11 +10,12 @@ import ( "github.com/opencontainers/runc/libcontainer/logs" _ "github.com/opencontainers/runc/libcontainer/nsenter" "github.com/sirupsen/logrus" - "github.com/urfave/cli" ) func init() { if len(os.Args) > 1 && os.Args[1] == "init" { + // This is the golang entry point for runc init, executed + // before main() but after libcontainer/nsenter's nsexec(). runtime.GOMAXPROCS(1) runtime.LockOSThread() @@ -38,13 +39,7 @@ func init() { panic(fmt.Sprintf("libcontainer: failed to configure logging: %v", err)) } logrus.Debug("child process in init()") - } -} -var initCommand = cli.Command{ - Name: "init", - Usage: `initialize the namespaces and launch the process (do not call it outside of runc)`, - Action: func(context *cli.Context) error { factory, _ := libcontainer.New("") if err := factory.StartInitialization(); err != nil { // as the error is sent back to the parent there is no need to log @@ -52,5 +47,5 @@ var initCommand = cli.Command{ os.Exit(1) } panic("libcontainer: container init failed to exec") - }, + } } diff --git a/main.go b/main.go index 45652ab32..f141e79b4 100644 --- a/main.go +++ b/main.go @@ -119,7 +119,6 @@ func main() { deleteCommand, eventsCommand, execCommand, - initCommand, killCommand, listCommand, pauseCommand, @@ -149,10 +148,7 @@ func main() { if err := reviseRootDir(context); err != nil { return err } - // let init configure logging on its own - if args := context.Args(); args != nil && args.First() == "init" { - return nil - } + return logs.ConfigureLogging(createLogConfig(context)) }