mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 12:36:38 +08:00
config: move account initialisation out into accounting
Before this change the initialisation for the accounting package was done in the config package for some strange historical reason.
This commit is contained in:
parent
1fed2d910c
commit
a7fd65bf2d
|
@ -386,6 +386,9 @@ func initConfig() {
|
|||
// Load the config
|
||||
configfile.LoadConfig(ctx)
|
||||
|
||||
// Start accounting
|
||||
accounting.Start(ctx)
|
||||
|
||||
// Hide console window
|
||||
if ci.NoConsole {
|
||||
terminal.HideConsole()
|
||||
|
|
|
@ -29,6 +29,18 @@ var ErrorMaxTransferLimitReachedFatal = fserrors.FatalError(ErrorMaxTransferLimi
|
|||
// transfer limit is reached and a graceful stop is required.
|
||||
var ErrorMaxTransferLimitReachedGraceful = fserrors.NoRetryError(ErrorMaxTransferLimitReached)
|
||||
|
||||
// Start sets up the accounting, in particular the bandwidth limiting
|
||||
func Start(ctx context.Context) {
|
||||
// Start the token bucket limiter
|
||||
TokenBucket.StartTokenBucket(ctx)
|
||||
|
||||
// Start the bandwidth update ticker
|
||||
TokenBucket.StartTokenTicker(ctx)
|
||||
|
||||
// Start the transactions per second limiter
|
||||
StartLimitTPS(ctx)
|
||||
}
|
||||
|
||||
// Account limits and accounts for one transfer
|
||||
type Account struct {
|
||||
stats *StatsInfo
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/accounting"
|
||||
"github.com/rclone/rclone/fs/config/configmap"
|
||||
"github.com/rclone/rclone/fs/config/configstruct"
|
||||
"github.com/rclone/rclone/fs/config/obscure"
|
||||
|
@ -232,15 +231,6 @@ func LoadConfig(ctx context.Context) {
|
|||
} else {
|
||||
fs.Debugf(nil, "Using config file from %q", ConfigPath)
|
||||
}
|
||||
|
||||
// Start the token bucket limiter
|
||||
accounting.TokenBucket.StartTokenBucket(ctx)
|
||||
|
||||
// Start the bandwidth update ticker
|
||||
accounting.TokenBucket.StartTokenTicker(ctx)
|
||||
|
||||
// Start the transactions per second limiter
|
||||
accounting.StartLimitTPS(ctx)
|
||||
}
|
||||
|
||||
// ErrorConfigFileNotFound is returned when the config file is not found
|
||||
|
|
|
@ -72,6 +72,7 @@ func Initialise() {
|
|||
config.ConfigPath = envConfig
|
||||
}
|
||||
configfile.LoadConfig(ctx)
|
||||
accounting.Start(ctx)
|
||||
if *Verbose {
|
||||
ci.LogLevel = fs.LogLevelDebug
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user