updating logrus configurations
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
ServerPort = ":8000" #leave format as is it expects a string with colon
|
ServerPort = ":8000" #leave format as is it expects a string with colon
|
||||||
ServerAddr = "192.168.1.8" #Put in the IP address you want to bind to
|
ServerAddr = "192.168.1.8" #Put in the IP address you want to bind to
|
||||||
LogLevel = "Info" # Options = Debug, Info, Warn, Error, Fatal, Panic
|
LogLevel = "Debug" # Options = Debug, Info, Warn, Error, Fatal, Panic
|
||||||
LogOutput = "stdout" #Options = file, stdout #file will print it to logs/server.log
|
LogOutput = "file" #Options = file, stdout #file will print it to logs/server.log
|
||||||
|
|
||||||
SeedRatioStop = 1.50 #automatically stops the torrent after it reaches this seeding ratio
|
SeedRatioStop = 1.50 #automatically stops the torrent after it reaches this seeding ratio
|
||||||
|
|
||||||
|
@@ -57,26 +57,23 @@ func CheckTorrentWatchFolder(c *cron.Cron, db *storm.DB, tclient *torrent.Client
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//CheckTorrents runs a upload ratio check, a queue check (essentially anything that should not be frontend dependent)
|
//CheckTorrentsCron runs a upload ratio check, a queue check (essentially anything that should not be frontend dependent)
|
||||||
func CheckTorrentsCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, config Settings.FullClientSettings) {
|
func CheckTorrentsCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, config Settings.FullClientSettings) {
|
||||||
c.AddFunc("@every 30s", func() {
|
c.AddFunc("@every 30s", func() {
|
||||||
Logger.Debug("Running a torrent Ratio and Queue Check")
|
Logger.Debug("Running a torrent Ratio and Queue Check")
|
||||||
torrentLocalArray := Storage.FetchAllStoredTorrents(db)
|
torrentLocalArray := Storage.FetchAllStoredTorrents(db)
|
||||||
torrentQueues := Storage.FetchQueues(db)
|
torrentQueues := Storage.FetchQueues(db)
|
||||||
for _, singleTorrentFromStorage := range torrentLocalArray {
|
for _, singleTorrentFromStorage := range torrentLocalArray {
|
||||||
//torrentQueues := Storage.FetchQueues(db)
|
|
||||||
var singleTorrent *torrent.Torrent
|
var singleTorrent *torrent.Torrent
|
||||||
for _, liveTorrent := range tclient.Torrents() { //matching the torrent from storage to the live torrent
|
for _, liveTorrent := range tclient.Torrents() { //matching the torrent from storage to the live torrent
|
||||||
if singleTorrentFromStorage.Hash == liveTorrent.InfoHash().String() {
|
if singleTorrentFromStorage.Hash == liveTorrent.InfoHash().String() {
|
||||||
singleTorrent = liveTorrent
|
singleTorrent = liveTorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//var TempHash metainfo.Hash
|
|
||||||
//calculatedTotalSize := CalculateDownloadSize(singleTorrentFromStorage, singleTorrent)
|
|
||||||
calculatedCompletedSize := CalculateCompletedSize(singleTorrentFromStorage, singleTorrent)
|
calculatedCompletedSize := CalculateCompletedSize(singleTorrentFromStorage, singleTorrent)
|
||||||
//TempHash = singleTorrent.InfoHash()
|
|
||||||
bytesCompleted := CalculateCompletedSize(singleTorrentFromStorage, singleTorrent)
|
bytesCompleted := CalculateCompletedSize(singleTorrentFromStorage, singleTorrent)
|
||||||
if float64(singleTorrentFromStorage.UploadedBytes)/float64(bytesCompleted) >= config.SeedRatioStop && singleTorrentFromStorage.TorrentUploadLimit == true { //If storage shows torrent stopped or if it is over the seeding ratio AND is under the global limit
|
if float64(singleTorrentFromStorage.UploadedBytes)/float64(bytesCompleted) >= config.SeedRatioStop && singleTorrentFromStorage.TorrentUploadLimit == true { //If storage shows torrent stopped or if it is over the seeding ratio AND is under the global limit
|
||||||
|
Logger.WithFields(logrus.Fields{"Action: Stopping torrent due to seed Ratio": singleTorrentFromStorage.TorrentName}).Info()
|
||||||
StopTorrent(singleTorrent, singleTorrentFromStorage, db)
|
StopTorrent(singleTorrent, singleTorrentFromStorage, db)
|
||||||
}
|
}
|
||||||
if len(torrentQueues.ActiveTorrents) < config.MaxActiveTorrents && singleTorrentFromStorage.TorrentStatus == "Queued" {
|
if len(torrentQueues.ActiveTorrents) < config.MaxActiveTorrents && singleTorrentFromStorage.TorrentStatus == "Queued" {
|
||||||
|
5
main.go
5
main.go
@@ -33,7 +33,7 @@ var (
|
|||||||
//Authenticated stores the value of the result of the client that connects to the server
|
//Authenticated stores the value of the result of the client that connects to the server
|
||||||
Authenticated = false
|
Authenticated = false
|
||||||
APP_ID = os.Getenv("APP_ID")
|
APP_ID = os.Getenv("APP_ID")
|
||||||
sendJSON = make(chan interface{})
|
sendJSON = make(chan interface{}) //channel for JSON messages
|
||||||
)
|
)
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{
|
var upgrader = websocket.Upgrader{
|
||||||
@@ -60,7 +60,6 @@ func handleMessages(conn *websocket.Conn) {
|
|||||||
func handleAuthentication(conn *websocket.Conn, db *storm.DB) {
|
func handleAuthentication(conn *websocket.Conn, db *storm.DB) {
|
||||||
msg := Engine.Message{}
|
msg := Engine.Message{}
|
||||||
err := conn.ReadJSON(&msg)
|
err := conn.ReadJSON(&msg)
|
||||||
//conn.WriteJSON(msg) //TODO just for testing, remove
|
|
||||||
payloadData, ok := msg.Payload.(map[string]interface{})
|
payloadData, ok := msg.Payload.(map[string]interface{})
|
||||||
clientAuthToken, tokenOk := payloadData["ClientAuthString"].(string)
|
clientAuthToken, tokenOk := payloadData["ClientAuthString"].(string)
|
||||||
fmt.Println("ClientAuthToken:", clientAuthToken, "TokenOkay", tokenOk, "PayloadData", payloadData, "PayloadData Okay?", ok)
|
fmt.Println("ClientAuthToken:", clientAuthToken, "TokenOkay", tokenOk, "PayloadData", payloadData, "PayloadData Okay?", ok)
|
||||||
@@ -97,7 +96,7 @@ func handleAuthentication(conn *websocket.Conn, db *storm.DB) {
|
|||||||
fmt.Println("Claims", claims["ClientName"], claims["Issuer"])
|
fmt.Println("Claims", claims["ClientName"], claims["Issuer"])
|
||||||
Authenticated = true
|
Authenticated = true
|
||||||
} else {
|
} else {
|
||||||
Logger.WithFields(logrus.Fields{"error": err}).Error("Authentication Error occured, cannot complete!")
|
Logger.WithFields(logrus.Fields{"error": err}).Error("Authentication Error occurred, cannot complete!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ func defaultConfig() FullClientSettings {
|
|||||||
var Config FullClientSettings
|
var Config FullClientSettings
|
||||||
Config.ID = 4 //Unique ID for StormDB
|
Config.ID = 4 //Unique ID for StormDB
|
||||||
Config.Version = 1.0
|
Config.Version = 1.0
|
||||||
Config.LoggingLevel = 3 //Warn level
|
Config.LoggingLevel = logrus.WarnLevel //Warn level
|
||||||
Config.TorrentConfig.DataDir = "downloads" //the absolute or relative path of the default download directory for torrents
|
Config.TorrentConfig.DataDir = "downloads" //the absolute or relative path of the default download directory for torrents
|
||||||
Config.TFileUploadFolder = "uploadedTorrents"
|
Config.TFileUploadFolder = "uploadedTorrents"
|
||||||
Config.TorrentConfig.Seed = true
|
Config.TorrentConfig.Seed = true
|
||||||
@@ -129,19 +129,19 @@ func FullClientSettingsNew() FullClientSettings {
|
|||||||
logOutput := viper.GetString("serverConfig.LogOutput")
|
logOutput := viper.GetString("serverConfig.LogOutput")
|
||||||
switch logLevelString { //Options = Debug 5, Info 4, Warn 3, Error 2, Fatal 1, Panic 0
|
switch logLevelString { //Options = Debug 5, Info 4, Warn 3, Error 2, Fatal 1, Panic 0
|
||||||
case "Panic":
|
case "Panic":
|
||||||
logLevel = 0
|
logLevel = logrus.PanicLevel
|
||||||
case "Fatal":
|
case "Fatal":
|
||||||
logLevel = 1
|
logLevel = logrus.FatalLevel
|
||||||
case "Error":
|
case "Error":
|
||||||
logLevel = 2
|
logLevel = logrus.ErrorLevel
|
||||||
case "Warn":
|
case "Warn":
|
||||||
logLevel = 3
|
logLevel = logrus.WarnLevel
|
||||||
case "Info":
|
case "Info":
|
||||||
logLevel = 4
|
logLevel = logrus.InfoLevel
|
||||||
case "Debug":
|
case "Debug":
|
||||||
logLevel = 5
|
logLevel = logrus.DebugLevel
|
||||||
default:
|
default:
|
||||||
logLevel = 3
|
logLevel = logrus.WarnLevel
|
||||||
|
|
||||||
}
|
}
|
||||||
//HTTP, proxy
|
//HTTP, proxy
|
||||||
|
Reference in New Issue
Block a user