1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-06 14:36:47 +00:00

feat(tunasync): add tunasynctl reload subcommand

这个提交包含在:
bigeagle
2016-06-15 14:01:10 +08:00
父节点 8cb46476cf
当前提交 d292f9b0e3
共有 3 个文件被更改,包括 61 次插入1 次删除

查看文件

@@ -225,6 +225,39 @@ func cmdJob(cmd tunasync.CmdVerb) cli.ActionFunc {
}
}
func cmdWorker(cmd tunasync.CmdVerb) cli.ActionFunc {
return func(c *cli.Context) error {
cmd := tunasync.ClientCmd{
Cmd: cmd,
WorkerID: c.String("worker"),
}
resp, err := tunasync.PostJSON(baseURL+cmdPath, cmd, client)
if err != nil {
return cli.NewExitError(
fmt.Sprintf("Failed to correctly send command: %s",
err.Error()),
1)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return cli.NewExitError(
fmt.Sprintf("Failed to parse response: %s", err.Error()),
1)
}
return cli.NewExitError(fmt.Sprintf("Failed to correctly send"+
" command: HTTP status code is not 200: %s", body),
1)
}
logger.Info("Succesfully send command")
return nil
}
}
func main() {
app := cli.NewApp()
app.EnableBashCompletion = true
@@ -304,6 +337,12 @@ func main() {
Flags: append(commonFlags, cmdFlags...),
Action: initializeWrapper(cmdJob(tunasync.CmdRestart)),
},
{
Name: "reload",
Usage: "Tell worker to reload configurations",
Flags: append(commonFlags, cmdFlags...),
Action: initializeWrapper(cmdWorker(tunasync.CmdReload)),
},
{
Name: "ping",
Flags: append(commonFlags, cmdFlags...),