Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Jul 24, 2023
1 parent 2719d5a commit 78129f2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@ func syncStorageFlags() []cli.Flag {
func clusterFlags() []cli.Flag {
return addCategories("CLUSTER", []cli.Flag{
&cli.StringFlag{
Name: "manager",
Usage: "manager address",
Name: "manager",
Usage: "the manager address used only by the worker node",
Hidden: true,
},
&cli.StringSliceFlag{
Name: "worker",
Usage: "hosts (separated by comma) to launch worker",
},
&cli.BoolFlag{
Name: "is-worker",
Usage: "start as a worker",
Hidden: true,
&cli.StringFlag{
Name: "manager-address",
Usage: "manager address",
},
})
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/sync/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func startManager(config *Config, tasks <-chan object.Object) (string, error) {
_, _ = w.Write([]byte("OK"))
})
var addr string
if config.Manager != "" && !config.IsWorker {
addr = config.Manager
if config.ManagerAddr != "" {
addr = config.ManagerAddr
} else {
ips, err := utils.FindLocalIPs()
if err != nil {
Expand Down Expand Up @@ -267,9 +267,9 @@ func launchWorker(address string, config *Config, wg *sync.WaitGroup) {
args = append(args, rpath)
if strings.HasSuffix(path, "juicefs") {
args = append(args, os.Args[1:]...)
args = append(args, "--is-worker", "--manager", address)
args = append(args, "--manager", address)
} else {
args = append(args, "--is-worker", "--manager", address)
args = append(args, "--manager", address)
args = append(args, os.Args[1:]...)
}
if !config.Verbose && !config.Quiet {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sync/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Config struct {
Limit int64
Manager string
Workers []string
IsWorker bool
ManagerAddr string
ListThreads int
ListDepth int
BWLimit int
Expand Down Expand Up @@ -150,7 +150,7 @@ func NewConfigFromCli(c *cli.Context) *Config {
Links: c.Bool("links"),
Limit: c.Int64("limit"),
Workers: c.StringSlice("worker"),
IsWorker: c.Bool("is-worker"),
ManagerAddr: c.String("manager-address"),
Manager: c.String("manager"),
BWLimit: c.Int("bwlimit"),
NoHTTPS: c.Bool("no-https"),
Expand Down
8 changes: 4 additions & 4 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error {
}

var bufferSize = 10240
if config.IsWorker {
if config.Manager != "" {
bufferSize = 100
}
tasks := make(chan object.Object, bufferSize)
Expand All @@ -991,7 +991,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error {
limiter = ratelimit.NewBucketWithRate(bps, int64(bps)*3)
}

progress := utils.NewProgress(config.Verbose || config.Quiet || config.IsWorker)
progress := utils.NewProgress(config.Verbose || config.Quiet || config.Manager != "")
handled = progress.AddCountBar("Scanned objects", 0)
skipped = progress.AddCountSpinner("Skipped objects")
pending = progress.AddCountSpinner("Pending objects")
Expand Down Expand Up @@ -1032,7 +1032,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error {
config.rules = rules
}

if !config.IsWorker {
if config.Manager == "" {
if len(config.Workers) > 0 {
addr, err := startManager(config, tasks)
if err != nil {
Expand Down Expand Up @@ -1067,7 +1067,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error {
pending.SetCurrent(0)
progress.Done()

if !config.IsWorker {
if config.Manager == "" {
msg := fmt.Sprintf("Found: %d, skipped: %d, copied: %d (%s)",
handled.Current(), skipped.Current(), copied.Current(), formatSize(copiedBytes.Current()))
if checked != nil {
Expand Down

0 comments on commit 78129f2

Please sign in to comment.