Skip to content

Commit

Permalink
fix: delete socket file before run (fixed #1262) (#1279)
Browse files Browse the repository at this point in the history
* fix: delete socket file before run (fixed #1262)

* refactor: remove useless logs
  • Loading branch information
vvisionnn authored May 9, 2022
1 parent e705ded commit fb56b27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"io"
"io/fs"
"os"
"strings"

"github.com/cloudreve/Cloudreve/v3/bootstrap"
Expand Down Expand Up @@ -67,6 +68,14 @@ func main() {

// 如果启用了Unix
if conf.UnixConfig.Listen != "" {
// delete socket file before listening
if _, err := os.Stat(conf.UnixConfig.Listen); err == nil {
if err = os.Remove(conf.UnixConfig.Listen); err != nil {
util.Log().Error("删除 socket 文件错误, %s", err)
return
}
}

util.Log().Info("开始监听 %s", conf.UnixConfig.Listen)
if err := api.RunUnix(conf.UnixConfig.Listen); err != nil {
util.Log().Error("无法监听[%s],%s", conf.UnixConfig.Listen, err)
Expand Down

0 comments on commit fb56b27

Please sign in to comment.