fix: delete socket file before run (fixed #1262) (#1279)

* fix: delete socket file before run (fixed #1262)

* refactor: remove useless logs
pull/1298/head
vvisionnn 3 years ago committed by GitHub
parent e705dedc22
commit fb56b27062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,7 @@ import (
"flag"
"io"
"io/fs"
"os"
"strings"
"github.com/cloudreve/Cloudreve/v3/bootstrap"
@ -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)

Loading…
Cancel
Save