-
Notifications
You must be signed in to change notification settings - Fork 506
/
client.go
34 lines (27 loc) · 884 Bytes
/
client.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
package cli
import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/telepresenceio/telepresence/v2/pkg/client/cli/cliutil"
)
// IsServerRunning reports whether or not the daemon server is running.
func IsServerRunning() bool {
return assertDaemonStarted() == nil
}
var errDaemonIsNotRunning = errors.New("the telepresence daemon has not been started")
var errConnectorIsNotRunning = errors.New("not connected")
// quit sends the quit message to the daemon and waits for it to exit.
func quit(cmd *cobra.Command, _ []string) error {
si := &sessionInfo{cmd: cmd}
ds, err := si.newDaemonState()
if err == nil {
// Let daemon kill the connector
defer ds.disconnect()
return ds.DeactivateState()
}
// Ensure the connector is killed even if daemon isn't running
if err := cliutil.QuitConnector(cmd.Context()); err != nil {
return err
}
return nil
}