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