b0db33f919
* captplanet standalone farmer setup * Bandwidth Allocation * utils.Close method changed to utils.LogClose * Get build temporarily working * Get/Put for PSClient should take payer bandwidth allocations rather than the NewPSClient function * Update example client to reflect changes in client API * Update ecclient to use latest PSClient, Make NewPSClient return error also * Updated pieceranger tests to check for errors; sign method should take byte array * Handle defers in store.go better * Fix defer functions in psdb.go * fun times * Protobuf bandwidthallocation data is now a byte array * Remove psservice package and merge it into pstore server * Write wrapper for database calls * Change all expiration names in protobuf to be more informative; add defer in retrieve; remove old comment * Make PSDB tests implementation independent rather than method independent * get rid of payer, renter in ecclient * add context monitoring in store and retrieve
106 lines
2.3 KiB
Go
106 lines
2.3 KiB
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"storj.io/storj/pkg/cfgstruct"
|
|
"storj.io/storj/pkg/kademlia"
|
|
"storj.io/storj/pkg/miniogw"
|
|
"storj.io/storj/pkg/overlay"
|
|
psserver "storj.io/storj/pkg/piecestore/rpc/server"
|
|
"storj.io/storj/pkg/pointerdb"
|
|
"storj.io/storj/pkg/process"
|
|
"storj.io/storj/pkg/provider"
|
|
proto "storj.io/storj/protos/overlay"
|
|
)
|
|
|
|
const (
|
|
farmerCount = 50
|
|
)
|
|
|
|
type HeavyClient struct {
|
|
Identity provider.IdentityConfig
|
|
Kademlia kademlia.Config
|
|
PointerDB pointerdb.Config
|
|
Overlay overlay.Config
|
|
}
|
|
|
|
type Farmer struct {
|
|
Identity provider.IdentityConfig
|
|
Kademlia kademlia.Config
|
|
Storage psserver.Config
|
|
}
|
|
|
|
var (
|
|
runCmd = &cobra.Command{
|
|
Use: "run",
|
|
Short: "Run all providers",
|
|
RunE: cmdRun,
|
|
}
|
|
|
|
runCfg struct {
|
|
HeavyClient HeavyClient
|
|
Farmers [farmerCount]Farmer
|
|
Gateway miniogw.Config
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(runCmd)
|
|
cfgstruct.Bind(runCmd.Flags(), &runCfg, cfgstruct.ConfDir(defaultConfDir))
|
|
}
|
|
|
|
func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
|
ctx := process.Ctx(cmd)
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
errch := make(chan error, len(runCfg.Farmers)+2)
|
|
|
|
// start heavy client
|
|
go func() {
|
|
_, _ = fmt.Printf("starting heavy client on %s\n",
|
|
runCfg.HeavyClient.Identity.Address)
|
|
errch <- runCfg.HeavyClient.Identity.Run(ctx,
|
|
runCfg.HeavyClient.Kademlia,
|
|
runCfg.HeavyClient.PointerDB,
|
|
runCfg.HeavyClient.Overlay)
|
|
}()
|
|
|
|
// start the farmers
|
|
for i := 0; i < len(runCfg.Farmers); i++ {
|
|
go func(i int) {
|
|
_, _ = fmt.Printf("starting farmer %d grpc on %s, kad on %s\n", i,
|
|
runCfg.Farmers[i].Identity.Address,
|
|
runCfg.Farmers[i].Kademlia.TODOListenAddr)
|
|
errch <- runCfg.Farmers[i].Identity.Run(ctx,
|
|
runCfg.Farmers[i].Kademlia,
|
|
runCfg.Farmers[i].Storage)
|
|
}(i)
|
|
identity, err := runCfg.Farmers[i].Identity.Load()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
miniogw.GlobalMockOverlay.Nodes[identity.ID.String()] = &proto.Node{
|
|
Id: identity.ID.String(),
|
|
Address: &proto.NodeAddress{
|
|
Transport: proto.NodeTransport_TCP,
|
|
Address: runCfg.Farmers[i].Identity.Address,
|
|
},
|
|
}
|
|
}
|
|
|
|
// start s3 gateway
|
|
go func() {
|
|
_, _ = fmt.Printf("starting minio gateway on %s\n",
|
|
runCfg.Gateway.IdentityConfig.Address)
|
|
errch <- runCfg.Gateway.Run(ctx)
|
|
}()
|
|
|
|
return <-errch
|
|
}
|