1
0
mirror of https://github.com/rancher/os.git synced 2025-08-10 02:58:15 +00:00

Merge pull request #2086 from SvenDowideit/add-autoformat-logging

Log autoformat script output to /var/log/boot/autoformat.log
This commit is contained in:
Sven Dowideit 2017-09-12 15:04:41 +10:00 committed by GitHub
commit fa14b6960b
3 changed files with 16 additions and 3 deletions

View File

@ -15,6 +15,9 @@ import (
) )
func bootstrapAction(c *cli.Context) error { func bootstrapAction(c *cli.Context) error {
log.InitLogger()
log.Info("Running cloud-init-save")
log.Debugf("bootstrapAction") log.Debugf("bootstrapAction")
if err := UdevSettle(); err != nil { if err := UdevSettle(); err != nil {
log.Errorf("Failed to run udev settle: %v", err) log.Errorf("Failed to run udev settle: %v", err)

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
exec &>> /var/log/boot/autoformat.log
set -ex set -ex
MAGIC=${MAGIC:-"boot2docker, please format-me"} MAGIC=${MAGIC:-"boot2docker, please format-me"}

View File

@ -359,11 +359,20 @@ func RunInit() error {
} }
// And all the files in /var/log/boot/ // And all the files in /var/log/boot/
// TODO: I wonder if we can put this code into the log module, and have things write to the buffer until we FsReady() // TODO: I wonder if we can put this code into the log module, and have things write to the buffer until we FsReady()
bootLog := "/var/log/boot/" bootLog := "/var/log/"
if files, err := ioutil.ReadDir(bootLog); err == nil { if files, err := ioutil.ReadDir(bootLog); err == nil {
for _, file := range files { for _, file := range files {
filePath := filepath.Join(bootLog, file.Name()) filePath := filepath.Join(bootLog, file.Name())
filesToCopy = append(filesToCopy, filePath) filesToCopy = append(filesToCopy, filePath)
log.Debugf("Swizzle: Found %s to save", filePath)
}
}
bootLog = "/var/log/boot/"
if files, err := ioutil.ReadDir(bootLog); err == nil {
for _, file := range files {
filePath := filepath.Join(bootLog, file.Name())
filesToCopy = append(filesToCopy, filePath)
log.Debugf("Swizzle: Found %s to save", filePath)
} }
} }
for _, name := range filesToCopy { for _, name := range filesToCopy {
@ -373,7 +382,7 @@ func RunInit() error {
log.Errorf("read cfg file (%s) %s", name, err) log.Errorf("read cfg file (%s) %s", name, err)
continue continue
} }
log.Debugf("Saved %s to memory", name) log.Debugf("Swizzle: Saved %s to memory", name)
configFiles[name] = content configFiles[name] = content
} }
} }
@ -405,7 +414,7 @@ func RunInit() error {
if err := util.WriteFileAtomic(name, content, fileMode); err != nil { if err := util.WriteFileAtomic(name, content, fileMode); err != nil {
log.Error(err) log.Error(err)
} }
log.Infof("Wrote log to %s", name) log.Infof("Swizzle: Wrote file to %s", name)
} }
if err := os.MkdirAll(config.VarRancherDir, os.ModeDir|0755); err != nil { if err := os.MkdirAll(config.VarRancherDir, os.ModeDir|0755); err != nil {
log.Error(err) log.Error(err)