From add7b936e31852c79087162a60cff94446ea23ee Mon Sep 17 00:00:00 2001 From: bigeagle Date: Sat, 19 Nov 2016 23:57:56 +0800 Subject: [PATCH] refactor(cmd): pinning cli.v1 --- cmd/tunasync/tunasync.go | 16 ++++++++-------- cmd/tunasynctl/tunasynctl.go | 4 +++- manager/config.go | 2 +- worker/cgroup.go | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/tunasync/tunasync.go b/cmd/tunasync/tunasync.go index 0a29552..c9bed28 100644 --- a/cmd/tunasync/tunasync.go +++ b/cmd/tunasync/tunasync.go @@ -8,10 +8,10 @@ import ( "syscall" "time" - "github.com/codegangsta/cli" "github.com/gin-gonic/gin" "github.com/pkg/profile" "gopkg.in/op/go-logging.v1" + "gopkg.in/urfave/cli.v1" tunasync "github.com/tuna/tunasync/internal" "github.com/tuna/tunasync/manager" @@ -25,7 +25,7 @@ var ( var logger = logging.MustGetLogger("tunasync") -func startManager(c *cli.Context) { +func startManager(c *cli.Context) error { tunasync.InitLogger(c.Bool("verbose"), c.Bool("debug"), c.Bool("with-systemd")) cfg, err := manager.LoadConfig(c.String("config"), c) @@ -45,9 +45,10 @@ func startManager(c *cli.Context) { logger.Info("Run tunasync manager server.") m.Run() + return nil } -func startWorker(c *cli.Context) { +func startWorker(c *cli.Context) error { tunasync.InitLogger(c.Bool("verbose"), c.Bool("debug"), c.Bool("with-systemd")) if !c.Bool("debug") { gin.SetMode(gin.ReleaseMode) @@ -103,6 +104,7 @@ func startWorker(c *cli.Context) { logger.Info("Run tunasync worker.") w.Run() + return nil } func main() { @@ -129,6 +131,8 @@ func main() { } app := cli.NewApp() + app.Name = "tunasync" + app.Usage = "tunasync mirror job management tool" app.EnableBashCompletion = true app.Version = "0.1" app.Commands = []cli.Command{ @@ -158,10 +162,6 @@ func main() { Name: "key", Usage: "Use SSL key from `FILE`", }, - cli.StringFlag{ - Name: "status-file", - Usage: "Write status file to `FILE`", - }, cli.StringFlag{ Name: "db-file", Usage: "Use `FILE` as the database file", @@ -205,7 +205,7 @@ func main() { }, cli.BoolFlag{ Name: "debug", - Usage: "Run manager in debug mode", + Usage: "Run worker in debug mode", }, cli.BoolFlag{ Name: "with-systemd", diff --git a/cmd/tunasynctl/tunasynctl.go b/cmd/tunasynctl/tunasynctl.go index 78789f8..bf725d1 100644 --- a/cmd/tunasynctl/tunasynctl.go +++ b/cmd/tunasynctl/tunasynctl.go @@ -11,8 +11,8 @@ import ( "time" "github.com/BurntSushi/toml" - "github.com/codegangsta/cli" "gopkg.in/op/go-logging.v1" + "gopkg.in/urfave/cli.v1" tunasync "github.com/tuna/tunasync/internal" ) @@ -323,6 +323,8 @@ func main() { app := cli.NewApp() app.EnableBashCompletion = true app.Version = "0.1" + app.Name = "tunasynctl" + app.Usage = "control client for tunasync manager" commonFlags := []cli.Flag{ cli.StringFlag{ diff --git a/manager/config.go b/manager/config.go index f05a2e8..04fa8bf 100644 --- a/manager/config.go +++ b/manager/config.go @@ -2,7 +2,7 @@ package manager import ( "github.com/BurntSushi/toml" - "github.com/codegangsta/cli" + "gopkg.in/urfave/cli.v1" ) // A Config is the top-level toml-serializaible config struct diff --git a/worker/cgroup.go b/worker/cgroup.go index 26ae7e9..a2d4072 100644 --- a/worker/cgroup.go +++ b/worker/cgroup.go @@ -116,6 +116,7 @@ func (c *cgroupHook) killAll() error { return nil } for _, pid := range taskList { + // TODO: deal with defunct processes logger.Debugf("Killing process: %d", pid) unix.Kill(pid, syscall.SIGKILL) }