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