mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
In this commit, a new Proxy service is added with a StopDaemon method. This method can be used to stop the Litd service. This will be useful in remote-mode itests where we want to restart Litd without also restarting LND. It also provides a nice way of shutting down Litd in remote-mode. A GetInfo method is also added to the service which for now just returns the Litd version. The reason for adding this method now is so that access to the new Proxy service can be tested in the itests withouth actually shutting down Litd.
63 lines
1.1 KiB
Go
63 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/lightninglabs/lightning-terminal/litrpc"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var litCommands = []cli.Command{
|
|
{
|
|
Name: "stop",
|
|
Usage: "shutdown the LiT daemon",
|
|
Category: "LiT",
|
|
Action: shutdownLit,
|
|
},
|
|
{
|
|
Name: "getinfo",
|
|
Usage: "Returns basic information related to the active " +
|
|
"daemon.",
|
|
Category: "LiT",
|
|
Action: getInfo,
|
|
},
|
|
}
|
|
|
|
func getInfo(ctx *cli.Context) error {
|
|
clientConn, cleanup, err := connectClient(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer cleanup()
|
|
client := litrpc.NewProxyClient(clientConn)
|
|
|
|
ctxb := context.Background()
|
|
resp, err := client.GetInfo(ctxb, &litrpc.GetInfoRequest{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
printRespJSON(resp)
|
|
|
|
return nil
|
|
}
|
|
|
|
func shutdownLit(ctx *cli.Context) error {
|
|
clientConn, cleanup, err := connectClient(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer cleanup()
|
|
client := litrpc.NewProxyClient(clientConn)
|
|
|
|
ctxb := context.Background()
|
|
_, err = client.StopDaemon(ctxb, &litrpc.StopDaemonRequest{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println("Successfully shutdown LiTd")
|
|
|
|
return nil
|
|
}
|