示例#1
0
func (s *CmdCtlStop) Run() (err error) {
	cli, err := GetCtlClient(s.G())
	if err != nil {
		return err
	}
	return cli.Stop(context.TODO(), 0)
}
示例#2
0
func (s *CmdCtlRestart) Run() error {
	configCli, err := GetConfigClient(s.G())
	if err != nil {
		return err
	}
	config, err := configCli.GetConfig(context.TODO(), 0)
	if err != nil {
		return err
	}

	cli, err := GetCtlClient(s.G())
	if err != nil {
		return err
	}
	if err = cli.Stop(context.TODO(), 0); err != nil {
		s.G().Log.Warning("Stop failed: %s", err)
		return err
	}

	// Wait a few seconds before the server stops
	s.G().Log.Info("Delaying for shutdown...")
	time.Sleep(2 * time.Second)
	s.G().Log.Info("Restart")
	_, err = ForkServer(s.G(), s.G().Env.GetCommandLine(), config.IsAutoForked)
	return err
}
示例#3
0
文件: cmd_ctl.go 项目: qbit/client
// CtlServiceStop will stop a running service via RPC call
func CtlServiceStop(g *libkb.GlobalContext) error {
	cli, err := GetCtlClient(g)
	if err != nil {
		return err
	}
	return cli.Stop(context.TODO(), keybase1.StopArg{ExitCode: keybase1.ExitCode_OK})
}
示例#4
0
func (s *CmdCtlRestart) Run() error {
	configCli, err := GetConfigClient(s.G())
	if err != nil {
		return err
	}
	config, err := configCli.GetConfig(context.TODO(), 0)
	if err != nil {
		return err
	}

	cli, err := GetCtlClient(s.G())
	if err != nil {
		return err
	}
	if err = cli.Stop(context.TODO(), keybase1.StopArg{ExitCode: keybase1.ExitCode_RESTART}); err != nil {
		s.G().Log.Warning("Stop failed: %s", err)
		return err
	}

	// If the watchdog started this process, it will do the restarting.
	// Otherwise we have to.
	if config.ForkType != keybase1.ForkType_WATCHDOG {
		// Wait a few seconds before the server stops
		s.G().Log.Info("Delaying for shutdown...")
		time.Sleep(2 * time.Second)
		s.G().Log.Info("Restart")
		_, err = ForkServer(s.G(), s.G().Env.GetCommandLine(), config.ForkType)
	}
	return err
}
示例#5
0
func (s *CmdCtlStop) Run() (err error) {
	cli, err := GetCtlClient(s.G())
	if err != nil {
		return err
	}
	return cli.Stop(context.TODO(), keybase1.StopArg{ExitCode: keybase1.ExitCode_OK})
}