Files
kato 2318684e93 refactor(core): add headless run and auto-restart
- Run without console by default
- Log to file once console hidden
- Recover panics in background goroutines
- Restart agent after unexpected errors
- Use shared instance launch helper
2026-09-01 20:12:12 +03:00

26 lines
480 B
Go

package helpers
import (
"os"
"path/filepath"
"tea.chunkbyte.com/kato/go-worm/lib/config"
)
// AttachLogFile appends application logs to logs/agent.log.
func AttachLogFile() error {
dir, err := config.LogsDir()
if err != nil {
return err
}
if err := os.MkdirAll(dir, 0o700); err != nil {
return err
}
f, err := os.OpenFile(filepath.Join(dir, "agent.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600)
if err != nil {
return err
}
SetLogOutput(f)
return nil
}