aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/backup.go4
-rw-r--r--weed/command/benchmark.go8
-rw-r--r--weed/command/filer.go7
-rw-r--r--weed/command/filer_copy.go18
-rw-r--r--weed/command/filer_replication.go8
-rw-r--r--weed/command/master.go14
-rw-r--r--weed/command/mount_std.go3
-rw-r--r--weed/command/s3.go9
-rw-r--r--weed/command/scaffold.go23
-rw-r--r--weed/command/server.go10
-rw-r--r--weed/command/shell.go4
-rw-r--r--weed/command/upload.go9
-rw-r--r--weed/command/volume.go7
-rw-r--r--weed/command/webdav.go2
14 files changed, 76 insertions, 50 deletions
diff --git a/weed/command/backup.go b/weed/command/backup.go
index 022e784c7..31e146965 100644
--- a/weed/command/backup.go
+++ b/weed/command/backup.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/security"
- "github.com/chrislusf/seaweedfs/weed/server"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
+ "github.com/chrislusf/seaweedfs/weed/util"
"github.com/spf13/viper"
"github.com/chrislusf/seaweedfs/weed/operation"
@@ -52,7 +52,7 @@ var cmdBackup = &Command{
func runBackup(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
grpcDialOption := security.LoadClientTLS(viper.Sub("grpc"), "client")
if *s.volumeId == -1 {
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go
index 6c64c4591..dd0fdb88e 100644
--- a/weed/command/benchmark.go
+++ b/weed/command/benchmark.go
@@ -4,9 +4,6 @@ import (
"bufio"
"context"
"fmt"
- "github.com/chrislusf/seaweedfs/weed/server"
- "github.com/spf13/viper"
- "google.golang.org/grpc"
"io"
"math"
"math/rand"
@@ -18,6 +15,9 @@ import (
"sync"
"time"
+ "github.com/spf13/viper"
+ "google.golang.org/grpc"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/security"
@@ -108,7 +108,7 @@ var (
func runBenchmark(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
b.grpcDialOption = security.LoadClientTLS(viper.Sub("grpc"), "client")
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.VERSION, runtime.GOOS, runtime.GOARCH)
diff --git a/weed/command/filer.go b/weed/command/filer.go
index d82781765..2aa022cd0 100644
--- a/weed/command/filer.go
+++ b/weed/command/filer.go
@@ -1,13 +1,14 @@
package command
import (
- "github.com/chrislusf/seaweedfs/weed/security"
- "github.com/spf13/viper"
"net/http"
"strconv"
"strings"
"time"
+ "github.com/chrislusf/seaweedfs/weed/security"
+ "github.com/spf13/viper"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/server"
@@ -77,7 +78,7 @@ var cmdFiler = &Command{
func runFiler(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
f.startFiler()
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go
index c18b9f055..8d8fead62 100644
--- a/weed/command/filer_copy.go
+++ b/weed/command/filer_copy.go
@@ -3,14 +3,6 @@ package command
import (
"context"
"fmt"
- "github.com/chrislusf/seaweedfs/weed/operation"
- "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
- "github.com/chrislusf/seaweedfs/weed/security"
- "github.com/chrislusf/seaweedfs/weed/server"
- "github.com/chrislusf/seaweedfs/weed/util"
- "github.com/chrislusf/seaweedfs/weed/wdclient"
- "github.com/spf13/viper"
- "google.golang.org/grpc"
"io"
"io/ioutil"
"net/http"
@@ -21,6 +13,14 @@ import (
"strings"
"sync"
"time"
+
+ "github.com/chrislusf/seaweedfs/weed/operation"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/security"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/chrislusf/seaweedfs/weed/wdclient"
+ "github.com/spf13/viper"
+ "google.golang.org/grpc"
)
var (
@@ -74,7 +74,7 @@ var cmdCopy = &Command{
func runCopy(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
if len(args) <= 1 {
return false
diff --git a/weed/command/filer_replication.go b/weed/command/filer_replication.go
index 82576afe6..c6e7f5dba 100644
--- a/weed/command/filer_replication.go
+++ b/weed/command/filer_replication.go
@@ -13,7 +13,7 @@ import (
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/gcssink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/s3sink"
"github.com/chrislusf/seaweedfs/weed/replication/sub"
- "github.com/chrislusf/seaweedfs/weed/server"
+ "github.com/chrislusf/seaweedfs/weed/util"
"github.com/spf13/viper"
)
@@ -36,9 +36,9 @@ var cmdFilerReplicate = &Command{
func runFilerReplicate(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
- weed_server.LoadConfiguration("replication", true)
- weed_server.LoadConfiguration("notification", true)
+ util.LoadConfiguration("security", false)
+ util.LoadConfiguration("replication", true)
+ util.LoadConfiguration("notification", true)
config := viper.GetViper()
var notificationInput sub.NotificationInput
diff --git a/weed/command/master.go b/weed/command/master.go
index 5a5bf2c0a..bda8493ed 100644
--- a/weed/command/master.go
+++ b/weed/command/master.go
@@ -1,6 +1,12 @@
package command
import (
+ "net/http"
+ "os"
+ "runtime"
+ "strconv"
+ "strings"
+
"github.com/chrislusf/raft/protobuf"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
@@ -10,11 +16,6 @@ import (
"github.com/gorilla/mux"
"github.com/spf13/viper"
"google.golang.org/grpc/reflection"
- "net/http"
- "os"
- "runtime"
- "strconv"
- "strings"
)
func init() {
@@ -56,7 +57,8 @@ var (
func runMaster(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
+ util.LoadConfiguration("master", false)
if *mMaxCpu < 1 {
*mMaxCpu = runtime.NumCPU()
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go
index 36c1f97a3..1d1214266 100644
--- a/weed/command/mount_std.go
+++ b/weed/command/mount_std.go
@@ -13,7 +13,6 @@ import (
"time"
"github.com/chrislusf/seaweedfs/weed/security"
- "github.com/chrislusf/seaweedfs/weed/server"
"github.com/jacobsa/daemonize"
"github.com/spf13/viper"
@@ -45,7 +44,7 @@ func runMount(cmd *Command, args []string) bool {
func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCenter string, chunkSizeLimitMB int,
allowOthers bool, ttlSec int, dirListingLimit int) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.VERSION, runtime.GOOS, runtime.GOARCH)
if dir == "" {
diff --git a/weed/command/s3.go b/weed/command/s3.go
index 014342766..e004bb066 100644
--- a/weed/command/s3.go
+++ b/weed/command/s3.go
@@ -1,13 +1,14 @@
package command
import (
- "github.com/chrislusf/seaweedfs/weed/security"
- "github.com/chrislusf/seaweedfs/weed/server"
- "github.com/spf13/viper"
"net/http"
"time"
+ "github.com/chrislusf/seaweedfs/weed/security"
+ "github.com/spf13/viper"
+
"fmt"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/s3api"
"github.com/chrislusf/seaweedfs/weed/util"
@@ -47,7 +48,7 @@ var cmdS3 = &Command{
func runS3(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
return s3StandaloneOptions.startS3Server()
diff --git a/weed/command/scaffold.go b/weed/command/scaffold.go
index e24d7b56a..2282658bb 100644
--- a/weed/command/scaffold.go
+++ b/weed/command/scaffold.go
@@ -10,7 +10,7 @@ func init() {
}
var cmdScaffold = &Command{
- UsageLine: "scaffold -config=[filer|notification|replication|security]",
+ UsageLine: "scaffold -config=[filer|notification|replication|security|master]",
Short: "generate basic configuration files",
Long: `Generate filer.toml with all possible configurations for you to customize.
@@ -19,7 +19,7 @@ var cmdScaffold = &Command{
var (
outputPath = cmdScaffold.Flag.String("output", "", "if not empty, save the configuration file to this directory")
- config = cmdScaffold.Flag.String("config", "filer", "[filer|notification|replication|security] the configuration file to generate")
+ config = cmdScaffold.Flag.String("config", "filer", "[filer|notification|replication|security|master] the configuration file to generate")
)
func runScaffold(cmd *Command, args []string) bool {
@@ -34,6 +34,8 @@ func runScaffold(cmd *Command, args []string) bool {
content = REPLICATION_TOML_EXAMPLE
case "security":
content = SECURITY_TOML_EXAMPLE
+ case "master":
+ content = MASTER_TOML_EXAMPLE
}
if content == "" {
println("need a valid -config option")
@@ -310,4 +312,21 @@ key = ""
`
+
+ MASTER_TOML_EXAMPLE = `
+# Put this file to one of the location, with descending priority
+# ./master.toml
+# $HOME/.seaweedfs/master.toml
+# /etc/seaweedfs/master.toml
+# this file is read by master
+
+[master.maintenance]
+scripts = """
+ ec.encode -fullPercent=95 -quietFor=1h
+ ec.rebuild -force
+ ec.balance -force
+ volume.balance -force
+"""
+
+`
)
diff --git a/weed/command/server.go b/weed/command/server.go
index 630ba72a7..437b0ad83 100644
--- a/weed/command/server.go
+++ b/weed/command/server.go
@@ -2,9 +2,6 @@ package command
import (
"fmt"
- "github.com/chrislusf/raft/protobuf"
- "github.com/chrislusf/seaweedfs/weed/security"
- "github.com/spf13/viper"
"net/http"
"os"
"runtime"
@@ -14,6 +11,10 @@ import (
"sync"
"time"
+ "github.com/chrislusf/raft/protobuf"
+ "github.com/chrislusf/seaweedfs/weed/security"
+ "github.com/spf13/viper"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/server"
@@ -107,7 +108,8 @@ func init() {
func runServer(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
+ util.LoadConfiguration("master", false)
if *serverOptions.cpuprofile != "" {
f, err := os.Create(*serverOptions.cpuprofile)
diff --git a/weed/command/shell.go b/weed/command/shell.go
index 95b62f0b5..79f8b8bf9 100644
--- a/weed/command/shell.go
+++ b/weed/command/shell.go
@@ -2,8 +2,8 @@ package command
import (
"github.com/chrislusf/seaweedfs/weed/security"
- "github.com/chrislusf/seaweedfs/weed/server"
"github.com/chrislusf/seaweedfs/weed/shell"
+ "github.com/chrislusf/seaweedfs/weed/util"
"github.com/spf13/viper"
)
@@ -28,7 +28,7 @@ var ()
func runShell(command *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
shellOptions.GrpcDialOption = security.LoadClientTLS(viper.Sub("grpc"), "client")
shellOptions.FilerHost = "localhost"
diff --git a/weed/command/upload.go b/weed/command/upload.go
index 1271725ba..25e938d9b 100644
--- a/weed/command/upload.go
+++ b/weed/command/upload.go
@@ -3,12 +3,13 @@ package command
import (
"encoding/json"
"fmt"
- "github.com/chrislusf/seaweedfs/weed/security"
- "github.com/chrislusf/seaweedfs/weed/server"
- "github.com/spf13/viper"
"os"
"path/filepath"
+ "github.com/chrislusf/seaweedfs/weed/security"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/spf13/viper"
+
"github.com/chrislusf/seaweedfs/weed/operation"
)
@@ -61,7 +62,7 @@ var cmdUpload = &Command{
func runUpload(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
grpcDialOption := security.LoadClientTLS(viper.Sub("grpc"), "client")
if len(args) == 0 {
diff --git a/weed/command/volume.go b/weed/command/volume.go
index 4e350b08d..c775ac5cf 100644
--- a/weed/command/volume.go
+++ b/weed/command/volume.go
@@ -1,8 +1,6 @@
package command
import (
- "github.com/chrislusf/seaweedfs/weed/security"
- "github.com/spf13/viper"
"net/http"
"os"
"runtime"
@@ -11,6 +9,9 @@ import (
"strings"
"time"
+ "github.com/chrislusf/seaweedfs/weed/security"
+ "github.com/spf13/viper"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/server"
@@ -83,7 +84,7 @@ var (
func runVolume(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
if *v.maxCpu < 1 {
*v.maxCpu = runtime.NumCPU()
diff --git a/weed/command/webdav.go b/weed/command/webdav.go
index 125893dfa..371c4a9ad 100644
--- a/weed/command/webdav.go
+++ b/weed/command/webdav.go
@@ -45,7 +45,7 @@ var cmdWebDav = &Command{
func runWebDav(cmd *Command, args []string) bool {
- weed_server.LoadConfiguration("security", false)
+ util.LoadConfiguration("security", false)
glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.VERSION, *webDavStandaloneOptions.port)