-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_ctl_restart.go
55 lines (45 loc) · 1.23 KB
/
cmd_ctl_restart.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"time"
"golang.org/x/net/context"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
)
func NewCmdCtlRestart(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "restart",
Usage: "Restart the background keybase service",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdCtlRestart{libkb.NewContextified(g)}, "restart", c)
cl.SetForkCmd(libcmdline.NoFork)
cl.SetNoStandalone()
},
}
}
type CmdCtlRestart struct {
libkb.Contextified
}
func (s *CmdCtlRestart) ParseArgv(ctx *cli.Context) error {
return nil
}
func (s *CmdCtlRestart) Run() error {
cli, err := GetCtlClient(s.G())
if err != nil {
return err
}
if err = cli.Stop(context.TODO(), 0); err != nil {
G.Log.Warning("Stop failed: %s", err)
return err
}
// Wait a few seconds before the server stops
G.Log.Info("Delaying for shutdown...")
time.Sleep(2 * time.Second)
G.Log.Info("Restart")
return ForkServer(s.G().Env.GetCommandLine(), s.G())
}
func (s *CmdCtlRestart) GetUsage() libkb.Usage {
return libkb.Usage{}
}