cli

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package cli 提供 xray-agent 的管理子命令:start / stop / status / restart / logs / upgrade / rollback / uninstall / lang / help。无参数或 run 走主循环(见 cmd/agent/main.go)。

Index

Constants

View Source
const AgentLogEnv = "XRAY_AGENT_LOG_FILE"

AgentLogEnv 手动(无 systemd)后台模式下的 agent 自身日志路径: start 通过环境变量把路径传给子进程,main 里按同一套滑动策略落盘。

Variables

This section is empty.

Functions

func Dashboard added in v0.2.0

func Dashboard(stdout io.Writer) int

Dashboard 裸执行 `xray-agent` 时的界面:状态头 + 分组命令面板。 之前这里只打一句「已由 systemd 托管」,对运维没有任何信息量。

func IsSubcommand

func IsSubcommand(arg string) bool

IsSubcommand 判断第一个参数是否为已知子命令或帮助别名。

func IsSystemdManaged

func IsSystemdManaged() bool

IsSystemdManaged 判断本机是否安装了 xray-agent 的 systemd 单元(无论服务是否在运行)。

func IsSystemdService

func IsSystemdService() bool

IsSystemdService 判断当前进程是否由 systemd 拉起:服务进程带 INVOCATION_ID 环境变量, 终端手动执行无此变量——用于区分「服务内启动」与「交互式误启动」。

func Run

func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int

Run 执行子命令,返回进程退出码(0 成功 / 1 执行失败 / 2 用法错误)。

func SetupAgentLog added in v0.2.0

func SetupAgentLog(path string, maxBytes int64) (io.Closer, error)

SetupAgentLog 后台模式下把 agent 自身日志同时写文件(与 xray 日志同一套滑动策略)。 返回的 io.Closer 由调用方在进程退出时关闭。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL