mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
update log
This commit is contained in:
@@ -55,7 +55,7 @@ func main() {
|
||||
settings.HttpAuth = params.HttpAuth
|
||||
log.Init(params.LogPath, params.WebLogPath)
|
||||
fmt.Println("=========== START ===========")
|
||||
fmt.Println("Build Go version:", runtime.Version())
|
||||
fmt.Println("TorrServer", version.Version+",", runtime.Version())
|
||||
if params.HttpAuth {
|
||||
log.TLogln("Use HTTP Auth file", settings.Path+"/accs.db")
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"server/log"
|
||||
"server/settings"
|
||||
)
|
||||
|
||||
func Preconfig(dkill bool) {
|
||||
@@ -22,10 +23,12 @@ func Preconfig(dkill bool) {
|
||||
go func() {
|
||||
for s := range sigc {
|
||||
if dkill {
|
||||
if (settings.BTsets.EnableDebug || s != syscall.SIGPIPE) {
|
||||
log.TLogln("Signal catched:", s)
|
||||
log.TLogln("To stop server, close it from web / api")
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func Init(path, webpath string) {
|
||||
//https://stackoverflow.com/a/36140590
|
||||
//fmt.Print(time.Now().UTC().Format("2006-01-02T15:04:05.999Z") + " TLOG " + string(bytes))
|
||||
log.SetFlags(log.Ldate|log.Ltime|log.LUTC|log.Lmsgprefix)
|
||||
log.SetPrefix("0000 TLOG ")
|
||||
log.SetPrefix("UTC0 TLOG ")
|
||||
log.SetOutput(ff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func SetSettings(set *sets.BTSets) {
|
||||
}
|
||||
lockApi.Lock()
|
||||
defer lockApi.Unlock()
|
||||
log.TLogln("drop all")
|
||||
log.TLogln("drop all torrents")
|
||||
dropAllTorrent()
|
||||
time.Sleep(time.Second * 2)
|
||||
log.TLogln("disconect")
|
||||
@@ -222,6 +222,7 @@ func SetSettings(set *sets.BTSets) {
|
||||
sets.SetBTSets(set)
|
||||
log.TLogln("connect")
|
||||
bts.Connect()
|
||||
time.Sleep(time.Second * 2)
|
||||
log.TLogln("end set settings")
|
||||
}
|
||||
|
||||
@@ -231,11 +232,16 @@ func SetDefSettings() {
|
||||
}
|
||||
lockApi.Lock()
|
||||
defer lockApi.Unlock()
|
||||
log.TLogln("drop all torrents")
|
||||
dropAllTorrent()
|
||||
time.Sleep(time.Second * 2)
|
||||
log.TLogln("disconect")
|
||||
bts.Disconnect()
|
||||
sets.SetDefault()
|
||||
log.TLogln("connect")
|
||||
bts.Connect()
|
||||
time.Sleep(time.Second * 5)
|
||||
time.Sleep(time.Second * 2)
|
||||
log.TLogln("end set default settings")
|
||||
}
|
||||
|
||||
func dropAllTorrent() {
|
||||
|
||||
@@ -48,11 +48,13 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
|
||||
reader := t.NewReader(file)
|
||||
|
||||
host, port, err := net.SplitHostPort(req.RemoteAddr)
|
||||
if sets.BTsets.EnableDebug {
|
||||
if err != nil {
|
||||
log.Println("Connect client")
|
||||
} else {
|
||||
log.Println("Connect client", host, port)
|
||||
}
|
||||
}
|
||||
|
||||
sets.SetViewed(&sets.Viewed{t.Hash().HexString(), fileID})
|
||||
|
||||
@@ -62,10 +64,12 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
|
||||
http.ServeContent(resp, req, file.Path(), time.Unix(t.Timestamp, 0), reader)
|
||||
|
||||
t.CloseReader(reader)
|
||||
if sets.BTsets.EnableDebug {
|
||||
if err != nil {
|
||||
log.Println("Disconnect client")
|
||||
} else {
|
||||
log.Println("Disconnect client", host, port)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ var (
|
||||
)
|
||||
|
||||
func Start(port string) {
|
||||
log.TLogln("Start TorrServer", version.Version)
|
||||
log.TLogln("Start TorrServer")
|
||||
ips := getLocalIps()
|
||||
if len(ips) > 0 {
|
||||
log.TLogln("IP:", ips)
|
||||
|
||||
Reference in New Issue
Block a user