Welcome to mirror list, hosted at ThFree Co, Russian Federation.

clear_logs_job.go « job « web - github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 34f13eaa8ce68adf1e50ed5835629a3cc848c8f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package job

import (
	"os"
	"x-ui/logger"
	"x-ui/xray"
)

type ClearLogsJob struct{}

func NewClearLogsJob() *ClearLogsJob {
	return new(ClearLogsJob)
}

// Here Run is an interface method of the Job interface
func (j *ClearLogsJob) Run() {
	logFiles := []string{xray.GetIPLimitLogPath(), xray.GetIPLimitBannedLogPath(), xray.GetAccessPersistentLogPath()}

	// clear log files
	for i := 0; i < len(logFiles); i++ {
		if err := os.Truncate(logFiles[i], 0); err != nil {
			logger.Warning("clear logs job err:", err)
		}
	}
}