fix: довести fix42 до production (cleanups, journald limits, docs)

This commit is contained in:
2026-05-21 15:31:11 +05:00
parent 782520848d
commit e1ecaf485f
22 changed files with 59 additions and 58 deletions
+15 -12
View File
@@ -12,16 +12,23 @@ import (
)
type journalctlLogLine struct {
Message string `json:"MESSAGE"`
Priority string `json:"PRIORITY"`
RealtimeTimestamp string `json:"__REALTIME_TIMESTAMP"`
Message string `json:"MESSAGE"`
Priority string `json:"PRIORITY"`
RealtimeTimestamp string `json:"__REALTIME_TIMESTAMP"`
}
func normalizeJournalLineLimit(value int, fallback int, max int) int {
if value <= 0 {
return fallback
}
if value > max {
return max
}
return value
}
func ReadHysteriaJournalLogs(numLine int) ([]vo.LogHysteria2Vo, int, error) {
lines := 100
if numLine > 0 {
lines = numLine
}
lines := normalizeJournalLineLimit(numLine, 100, 300)
output, err := util.Exec(fmt.Sprintf("journalctl --no-pager -u hysteria-server.service -n %d -o json", lines))
if err != nil {
@@ -52,10 +59,7 @@ func ReadHysteriaJournalLogs(numLine int) ([]vo.LogHysteria2Vo, int, error) {
}
func ExportHysteriaJournalLogs(numLine int) (string, error) {
lines := 5000
if numLine > 0 {
lines = numLine
}
lines := normalizeJournalLineLimit(numLine, 5000, 10000)
return util.Exec(fmt.Sprintf("journalctl --no-pager -u hysteria-server.service -n %d -o short-iso", lines))
}
@@ -117,4 +121,3 @@ func mapJournalPriorityToLevel(priority string) string {
return "info"
}
}