add web port check on start

This commit is contained in:
nikk gitanes
2021-08-09 01:34:58 +03:00
parent 202c622d07
commit 6af78cf041

View File

@@ -2,6 +2,7 @@ package server
import (
"io/ioutil"
"net"
"os"
"path/filepath"
@@ -15,9 +16,19 @@ func Start(port string, roSets bool) {
if port == "" {
port = "8090"
}
log.TLogln("Check web port", port)
l, err := net.Listen("tcp", ":"+port)
if l != nil {
l.Close()
}
if err != nil {
log.TLogln("Port", port, "already in use! Abort")
os.Exit(1)
} else {
go cleanCache()
web.Start(port)
}
}
func cleanCache() {
if !settings.BTsets.UseDisk || settings.BTsets.TorrentsSavePath == "/" || settings.BTsets.TorrentsSavePath == "" {