mirror of
https://github.com/rancher/os.git
synced 2025-09-02 07:15:41 +00:00
Cleanup logging
This commit is contained in:
@@ -101,10 +101,11 @@ func loadImages(cfg *config.Config) error {
|
||||
|
||||
defer input.Close()
|
||||
|
||||
log.Debugf("Loading images from %s", inputFileName)
|
||||
log.Infof("Loading images from %s", inputFileName)
|
||||
err = client.LoadImage(dockerClient.LoadImageOptions{
|
||||
InputStream: input,
|
||||
})
|
||||
log.Infof("Done loading images from %s", inputFileName)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -121,12 +122,11 @@ func runContainers(cfg *config.Config) error {
|
||||
containerConfigs = []config.ContainerConfig{*cfg.RescueContainer}
|
||||
}
|
||||
|
||||
for _, containerConfig := range containerConfigs {
|
||||
for i, containerConfig := range containerConfigs {
|
||||
container := docker.NewContainer(config.DOCKER_SYSTEM_HOST, &containerConfig)
|
||||
container.Parse()
|
||||
|
||||
if util.Contains(cfg.Disable, containerConfig.Id) {
|
||||
log.Debugf("%s is disabled : %v", containerConfig.Id, cfg.Disable)
|
||||
log.Infof("%s is disabled : %v", containerConfig.Id, cfg.Disable)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -139,8 +139,8 @@ func runContainers(cfg *config.Config) error {
|
||||
}
|
||||
}
|
||||
|
||||
log.Infof("Running [%d/%d] %s", i+1, len(containerConfigs), containerConfig.Id)
|
||||
container.StartAndWait()
|
||||
log.Debugf("Running %s", containerConfig.Id)
|
||||
|
||||
if container.Err != nil {
|
||||
log.Errorf("Failed to run %v: %v", containerConfig.Id, container.Err)
|
||||
|
26
init/init.go
26
init/init.go
@@ -25,6 +25,9 @@ var (
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
}
|
||||
postDirs []string = []string{
|
||||
"/var/log",
|
||||
}
|
||||
mounts [][]string = [][]string{
|
||||
[]string{"devtmpfs", "/dev", "devtmpfs", ""},
|
||||
[]string{"none", "/dev/pts", "devpts", ""},
|
||||
@@ -99,6 +102,7 @@ func createMounts(mounts ...[]string) error {
|
||||
}
|
||||
|
||||
func remountRo(cfg *config.Config) error {
|
||||
log.Info("Remouting root read only")
|
||||
return util.Remount("/", "ro")
|
||||
}
|
||||
|
||||
@@ -198,10 +202,18 @@ func sysInit(cfg *config.Config) error {
|
||||
}
|
||||
|
||||
func execDocker(cfg *config.Config) error {
|
||||
log.Info("Launching Docker")
|
||||
//os.Stdin.Close()
|
||||
//os.Stdout.Close()
|
||||
//os.Stderr.Close()
|
||||
log.Info("Launching System Docker")
|
||||
if !cfg.Debug {
|
||||
output, err := os.Create("/var/log/system-docker.log")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
syscall.Dup2(int(output.Fd()), int(os.Stdout.Fd()))
|
||||
syscall.Dup2(int(output.Fd()), int(os.Stderr.Fd()))
|
||||
}
|
||||
|
||||
os.Stdin.Close()
|
||||
return syscall.Exec(DOCKER, cfg.SystemDockerArgs, os.Environ())
|
||||
}
|
||||
|
||||
@@ -216,7 +228,7 @@ func mountState(cfg *config.Config) error {
|
||||
|
||||
if cfg.State.Dev != "" {
|
||||
dev := util.ResolveDevice(cfg.State.Dev)
|
||||
log.Debugf("Mounting state device %s to %s", dev, STATE)
|
||||
log.Infof("Mounting state device %s to %s", dev, STATE)
|
||||
|
||||
fsType := cfg.State.FsType
|
||||
if fsType == "auto" {
|
||||
@@ -252,6 +264,7 @@ func RunInit() error {
|
||||
return createDirs(dirs...)
|
||||
},
|
||||
func(cfg *config.Config) error {
|
||||
log.Info("Setting up mounts")
|
||||
return createMounts(mounts...)
|
||||
},
|
||||
func(cfg *config.Config) error {
|
||||
@@ -276,6 +289,9 @@ func RunInit() error {
|
||||
extractModules,
|
||||
loadModules,
|
||||
mountState,
|
||||
func(cfg *config.Config) error {
|
||||
return createDirs(postDirs...)
|
||||
},
|
||||
func(cfg *config.Config) error {
|
||||
return createMounts(postMounts...)
|
||||
},
|
||||
|
Reference in New Issue
Block a user