github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/main/commands/all/api/logger_restart.go (about)

     1  package api
     2  
     3  import (
     4  	logService "github.com/xmplusdev/xmcore/app/log/command"
     5  	"github.com/xmplusdev/xmcore/main/commands/base"
     6  )
     7  
     8  var cmdRestartLogger = &base.Command{
     9  	CustomFlags: true,
    10  	UsageLine:   "{{.Exec}} api restartlogger [--server=127.0.0.1:8080]",
    11  	Short:       "Restart the logger",
    12  	Long: `
    13  Restart the logger of Xray.
    14  Arguments:
    15  	-s, -server 
    16  		The API server address. Default 127.0.0.1:8080
    17  	-t, -timeout
    18  		Timeout seconds to call API. Default 3
    19  `,
    20  	Run: executeRestartLogger,
    21  }
    22  
    23  func executeRestartLogger(cmd *base.Command, args []string) {
    24  	setSharedFlags(cmd)
    25  	cmd.Flag.Parse(args)
    26  
    27  	conn, ctx, close := dialAPIServer()
    28  	defer close()
    29  
    30  	client := logService.NewLoggerServiceClient(conn)
    31  	r := &logService.RestartLoggerRequest{}
    32  	resp, err := client.RestartLogger(ctx, r)
    33  	if err != nil {
    34  		base.Fatalf("failed to restart logger: %s", err)
    35  	}
    36  	showJSONResponse(resp)
    37  }