fix(proxmox): improve journalctl with log tailing fallback for non-systemd systems

- Format tail command with fallback retry logic
- Add /var/log/messages fallback when no services specified

Improves log viewing reliability on systems without systemd support.
This commit is contained in:
yusing
2026-01-28 22:41:11 +08:00
parent d1c79acf87
commit 442e4a0972
2 changed files with 10 additions and 2 deletions

View File

@@ -31,14 +31,15 @@ func formatTail(files []string, limit int) (string, error) {
}
}
var command strings.Builder
command.WriteString("tail -f -q --retry ")
command.WriteString("tail -f -q ")
for _, file := range files {
fmt.Fprintf(&command, " %q ", file)
}
if limit > 0 {
fmt.Fprintf(&command, " -n %d", limit)
}
return command.String(), nil
// try --retry first, if it fails, try the command again
return fmt.Sprintf("sh -c '%s --retry 2>/dev/null || %s'", command.String(), command.String()), nil
}
func formatJournalctl(services []string, limit int) (string, error) {