Skip to content

Commit

Permalink
Rebase and simplify
Browse files Browse the repository at this point in the history
Signed-off-by: fzxiao233 <fzxiao@outlook.com>
  • Loading branch information
AlotOfBlahaj committed Mar 22, 2021
1 parent 2428fb0 commit 90eea5c
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 2,190 deletions.
22 changes: 0 additions & 22 deletions config/config.go
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"github.com/fsnotify/fsnotify"
"github.com/mitchellh/mapstructure"
"github.com/rclone/rclone/fs"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"log"
Expand All @@ -23,7 +22,6 @@ type UsersConfig struct {
DownloadDir string
NeedDownload bool
TransBiliId string
UserHeaders map[string]string
ExtraConfig map[string]interface{}
}
type ModuleConfig struct {
Expand All @@ -46,10 +44,6 @@ type MainConfig struct {
DownloadDir []string
UploadDir string
Module []ModuleConfig
PprofHost string
OutboundAddrs []string
DomainRewrite map[string]([]string)
RedisHost string
ExpressPort string
EnableTS2MP4 bool
ExtraConfig map[string]interface{}
Expand Down Expand Up @@ -123,10 +117,6 @@ func ReloadConfig() (bool, error) {
if err != nil {
fmt.Printf("Struct config error: %s", err)
}
/*modules := viper.AllSettings()["module"].([]interface{})
for i := 0; i < len(modules); i++ {
Config.Module[i].ExtraConfig = modules[i].(map[string]interface{})
}*/
Config = config
UpdateLogLevel()
return true, nil
Expand All @@ -147,18 +137,6 @@ func LevelStrParse(levelStr string) (level logrus.Level) {
}

func UpdateLogLevel() {
fs.Config.LogLevel = fs.LogLevelInfo
if Config.RLogLevel == "debug" {
fs.Config.LogLevel = fs.LogLevelDebug
} else if Config.RLogLevel == "info" {
fs.Config.LogLevel = fs.LogLevelInfo
} else if Config.RLogLevel == "warn" {
fs.Config.LogLevel = fs.LogLevelWarning
} else if Config.RLogLevel == "error" {
fs.Config.LogLevel = fs.LogLevelError
}
logrus.Printf("Set rclone logrus level to %s", fs.Config.LogLevel)

if ConsoleHook != nil {
level := LevelStrParse(Config.LogLevel)
ConsoleHook.LogLevel = level
Expand Down
18 changes: 0 additions & 18 deletions config/logs.go
Expand Up @@ -3,9 +3,7 @@ package config
import (
"fmt"
"github.com/fzxiao233/Vtb_Record/utils"
"github.com/knq/sdhook"
"github.com/orandin/lumberjackrus"
"github.com/rclone/rclone/fs"
"github.com/sirupsen/logrus"
"io"
"io/ioutil"
Expand Down Expand Up @@ -46,7 +44,6 @@ func (hook *WriterHook) Levels() []logrus.Level {

var ConsoleHook *WriterHook
var FileHook *lumberjackrus.Hook
var GoogleHook *sdhook.StackdriverHook

// Can't be func init as we need the parsed config
func InitLog() {
Expand Down Expand Up @@ -94,20 +91,5 @@ func InitLog() {

logrus.AddHook(FileHook)

GoogleHook, err = sdhook.New(
sdhook.GoogleLoggingAgent(),
sdhook.LogName(Config.LogFile),
sdhook.Levels(logrus.AllLevels[:logrus.DebugLevel+1]...),
)
if err != nil {
logrus.WithField("prof", true).Warnf("Failed to initialize the sdhook: %v", err)
} else {
logrus.AddHook(GoogleHook)
}

fs.LogPrint = func(level fs.LogLevel, text string) {
logrus.WithField("src", "rclone").Infof(fmt.Sprintf("%-6s: %s", level, text))
}

UpdateLogLevel()
}
38 changes: 0 additions & 38 deletions config/prof.go
@@ -1,11 +1,7 @@
package config

import (
"context"
"github.com/gogf/greuse"
log "github.com/sirupsen/logrus"
"net"
"net/http"
"runtime"
"runtime/debug"
"time"
Expand All @@ -27,38 +23,7 @@ func PrintMemUsage() {
m.NumGC)
}

var PprofServer *http.Server

func InitProfiling() {
go func() {
logger := log.WithField("prof", true)
ticker := time.NewTicker(time.Minute * 1)
for {
//go http.ListenAndServe("0.0.0.0:49314", nil)
if PprofServer == nil || PprofServer.Addr != Config.PprofHost {
logger.Warnf("Starting pprof server")
if PprofServer != nil {
go PprofServer.Shutdown(context.Background())
}
//PprofServer = &http.Server{Addr: config.Config.PprofHost, Handler: nil}
listener, err := greuse.Listen("tcp", Config.PprofHost)
if listener == nil {
logger.Warnf("Error creating reusable listener, creating a normal one instead!")
listener, err = net.Listen("tcp", Config.PprofHost)
}
if err != nil {
logger.WithError(err).Warnf("Failed to reuse-listen addr")
}
PprofServer = &http.Server{
Addr: Config.PprofHost,
}
//go PprofServer.ListenAndServe()
go PprofServer.Serve(listener)
}
<-ticker.C
}
}()

go func() {
ticker := time.NewTicker(time.Minute * 1)
for {
Expand All @@ -70,13 +35,10 @@ func InitProfiling() {
go func() {
ticker := time.NewTicker(time.Millisecond * 3000)
for {
//start := time.Now()
runtime.GC()
//log.WithField("prof", true).Debugf("G C & scvg use %s", time.Now().Sub(start))
<-ticker.C
}
}()

ticker := time.NewTicker(time.Second * 3)
for {
start := time.Now()
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Expand Up @@ -5,15 +5,14 @@ go 1.13
require (
github.com/bitly/go-simplejson v0.5.0
github.com/etherlabsio/go-m3u8 v0.1.2
github.com/fsnotify/fsnotify v1.4.7
github.com/fsnotify/fsnotify v1.4.9
github.com/fzxiao233/Go-Emoji-Utils v0.0.0-20200305114615-005e99b02c2f
github.com/go-redis/redis v6.15.8+incompatible
github.com/go-redis/redis/v8 v8.7.1
github.com/gogf/greuse v1.1.0
github.com/hashicorp/golang-lru v0.5.4
github.com/knq/sdhook v0.0.0-20190801142816-0b7fa827d09a
github.com/mitchellh/mapstructure v1.1.2
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/orandin/lumberjackrus v1.0.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/rclone/rclone v1.52.2
Expand All @@ -23,8 +22,7 @@ require (
github.com/tidwall/pretty v1.0.1 // indirect
github.com/valyala/bytebufferpool v1.0.0
go.uber.org/ratelimit v0.1.0
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/protobuf v1.23.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand Down
24 changes: 0 additions & 24 deletions live/plugins/pubsub.go

This file was deleted.

49 changes: 0 additions & 49 deletions live/plugins/uploader.go

This file was deleted.

0 comments on commit 90eea5c

Please sign in to comment.