From 4fb0823d60b89ffc37e8017d2861a20bc38ce4a7 Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Tue, 22 Sep 2020 10:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89mac=E4=B8=8D?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/server.go | 10 ++++------ controller/timer.go | 40 ---------------------------------------- 2 files changed, 4 insertions(+), 46 deletions(-) delete mode 100644 controller/timer.go diff --git a/cmd/server.go b/cmd/server.go index 30505c2..5f8cbd7 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -6,10 +6,8 @@ import ( ginSwagger "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" "github.com/taoshihan1991/imaptool/config" - "github.com/taoshihan1991/imaptool/controller" "github.com/taoshihan1991/imaptool/docs" "github.com/taoshihan1991/imaptool/router" - "github.com/taoshihan1991/imaptool/tools" "log" "os" "os/exec" @@ -50,7 +48,7 @@ func run(){ } baseServer := "0.0.0.0:"+port - tcpBaseServer := "0.0.0.0:"+tcpport + //tcpBaseServer := "0.0.0.0:"+tcpport log.Println("start server...\r\ngo:http://" + baseServer) engine := gin.Default() engine.LoadHTMLGlob("static/html/*") @@ -69,10 +67,10 @@ func run(){ //docs.SwaggerInfo.Schemes = []string{"http"} engine.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - logFile, _ := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660) - tools.RedirectStderr(logFile) + //logFile, _ := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660) + //tools.RedirectStderr(logFile) //tcp服务 - go controller.NewTcpServer(tcpBaseServer) + //go controller.NewTcpServer(tcpBaseServer) engine.Run(baseServer) } \ No newline at end of file diff --git a/controller/timer.go b/controller/timer.go deleted file mode 100644 index d2ed187..0000000 --- a/controller/timer.go +++ /dev/null @@ -1,40 +0,0 @@ -//+build !linux - -package controller - -import ( - "github.com/taoshihan1991/imaptool/config" - "os" - "path/filepath" - "runtime" - "syscall" - "time" -) - -var osType = runtime.GOOS - -const expireTime = 30 * 60 - -//检测权限文件是否过期,超过30分钟删除掉 -func TimerSessFile() { - go func() { - for { - time.Sleep(time.Second * 10) - files, _ := filepath.Glob(config.Dir + "sess_*") - for _, file := range files { - fileInfo, _ := os.Stat(file) - var createTime int64 - now := time.Now().Unix() - if osType == "windows" { - wFileSys := fileInfo.Sys().(*syscall.Win32FileAttributeData) - tNanSeconds := wFileSys.CreationTime.Nanoseconds() /// 返回的是纳秒 - createTime = tNanSeconds / 1e9 ///秒 - } - diffTime := now - createTime - if diffTime > expireTime { - os.Remove(file) - } - } - } - }() -}