This commit is contained in:
Liang Ding 2022-10-25 10:06:15 +08:00
parent fc4db17217
commit a20a19182b
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 7 additions and 76 deletions

View file

@ -24,7 +24,6 @@ import (
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
"github.com/olahol/melody"
"github.com/siyuan-note/logging"
)
func GetRemoteAddr(session *melody.Session) string {
@ -64,22 +63,3 @@ func isPortOpen(port string) bool {
}
return false
}
func tryToListenPort() bool {
listener, err := net.Listen("tcp", "127.0.0.1:"+ServerPort)
if nil != err {
time.Sleep(time.Second * 3)
listener, err = net.Listen("tcp", "127.0.0.1:"+ServerPort)
if nil != err {
logging.LogErrorf("try to listen port [%s] failed: %s", ServerPort, err)
return false
}
}
if err = listener.Close(); nil != err {
time.Sleep(time.Second * 1)
if err = listener.Close(); nil != err {
logging.LogErrorf("close listen port [%s] failed: %s", ServerPort, err)
}
}
return true
}