mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-06-03 01:44:53 +00:00
art: Check out if we have to create the log file
This commit is contained in:
parent
f185430669
commit
7052c49621
@ -35,12 +35,18 @@ func Run(opts ...Option) error {
|
||||
}
|
||||
|
||||
os.MkdirAll("/var/log/c3os", 0600) //nolint:errcheck
|
||||
|
||||
fileName := filepath.Join("/var/log/c3os", "agent-provider.log")
|
||||
err = ioutil.WriteFile(fileName, []byte{}, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
// Create if not exist
|
||||
if _, err := os.Stat(fileName); err != nil {
|
||||
err = ioutil.WriteFile(fileName, []byte{}, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Tail to the log
|
||||
t, err := tail.TailFile(fileName, tail.Config{Follow: true})
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user