Remove get torrents count config and use worker pool on all places
This commit is contained in:
@@ -54,7 +54,7 @@ func MainApp(configPath string) {
|
||||
|
||||
apiClient := http.NewHTTPClient(
|
||||
config.GetToken(),
|
||||
config.GetRetriesUntilFailed(), // default retries = 2, so this is 4
|
||||
config.GetRetriesUntilFailed(), // default retries = 2
|
||||
config.GetApiTimeoutSecs(), // default api timeout = 60
|
||||
false, // ipv6 support is not needed for api client
|
||||
config,
|
||||
@@ -79,19 +79,6 @@ func MainApp(configPath string) {
|
||||
log.Named("download_client"),
|
||||
)
|
||||
|
||||
api := realdebrid.NewRealDebrid(
|
||||
apiClient,
|
||||
unrestrictClient,
|
||||
downloadClient,
|
||||
config,
|
||||
log.Named("realdebrid"),
|
||||
)
|
||||
|
||||
premium.MonitorPremiumStatus(
|
||||
api,
|
||||
zurglog,
|
||||
)
|
||||
|
||||
workerPool, err := ants.NewPool(config.GetNumOfWorkers())
|
||||
if err != nil {
|
||||
zurglog.Errorf("Failed to create worker pool: %v", err)
|
||||
@@ -99,6 +86,21 @@ func MainApp(configPath string) {
|
||||
}
|
||||
defer workerPool.Release()
|
||||
|
||||
api := realdebrid.NewRealDebrid(
|
||||
apiClient,
|
||||
unrestrictClient,
|
||||
downloadClient,
|
||||
workerPool,
|
||||
config,
|
||||
log.Named("realdebrid"),
|
||||
)
|
||||
|
||||
premium.MonitorPremiumStatus(
|
||||
workerPool,
|
||||
api,
|
||||
zurglog,
|
||||
)
|
||||
|
||||
torrentMgr := torrent.NewTorrentManager(
|
||||
config,
|
||||
api,
|
||||
@@ -121,12 +123,12 @@ func MainApp(configPath string) {
|
||||
)
|
||||
|
||||
//// pprof
|
||||
// go func() {
|
||||
// if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
|
||||
// zurglog.Errorf("Failed to start pprof: %v", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// }()
|
||||
workerPool.Submit(func() {
|
||||
if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
|
||||
zurglog.Errorf("Failed to start pprof: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
addr := fmt.Sprintf("%s:%s", config.GetHost(), config.GetPort())
|
||||
zurglog.Infof("Starting server on %s", addr)
|
||||
|
||||
Reference in New Issue
Block a user