Documentation
¶
Index ¶
Constants ¶
View Source
const ( CliName = "dpi-analyze" Description = "dpi CLI" CliVersion = "1.1.0.241211_beta" )
Variables ¶
View Source
var CleanCmd = &cobra.Command{
Use: "clean",
Short: "清空所有数据",
Run: cleanRun,
}
View Source
var PsCmd = &cobra.Command{ Use: "ps", Short: "List DPI Server", Run: func(cmd *cobra.Command, args []string) { var processes [][]string entries, err := os.ReadDir(config.RunDir) if err != nil { fmt.Println("Error reading run directory:", err) return } for _, entry := range entries { if !entry.IsDir() { split := strings.Split(entry.Name(), ".") if split[len(split)-1] != "pid" { continue } pidFile := filepath.Join(config.RunDir, entry.Name()) pidBytes, err := os.ReadFile(pidFile) if err != nil { fmt.Printf("Error reading PID file %s: %v\n", pidFile, err) continue } pidStr := strings.TrimSpace(string(pidBytes)) pid, err := strconv.Atoi(pidStr) if err != nil { fmt.Printf("Invalid PID in file %s: %s\n", pidFile, pidStr) continue } processInfo := getProcessInfo(pid) if processInfo != nil { processes = append(processes, processInfo) } } } displayProcesses(processes) }, }
View Source
var RestartCmd = &cobra.Command{ Use: "restart", Short: "Restart one or more running server", PreRun: func(cmd *cobra.Command, args []string) { if len(args) == 0 { _ = cmd.Help() os.Exit(0) } }, }
View Source
var RunCmd = &cobra.Command{ Use: "run [command]", Short: "Create and run server", PreRun: func(cmd *cobra.Command, args []string) { if len(args) == 0 { _ = cmd.Help() os.Exit(0) } }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.