Skip to content

Commit 75403a8

Browse files
committed
change flag and update README.md
1 parent 9029d3b commit 75403a8

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ nmngd start-web ~/.rpc-gaia \
4545
--exr-rpc-url https://rpc1.cosmos.m.valoper.io \
4646
--exr-rest-url https://rest1.cosmos.m.valoper.io \
4747
--exr-favicon-url https://cosmos.m.valoper.io/favicon.ico \
48-
--exr-logo-url https://cosmos.m.valoper.io/logo.png
48+
--exr-logo-url https://cosmos.m.valoper.io/logo.png \
49+
--monitor-disks /mount/data1 --monitor-disks /mount/data2
4950
```
5051
Generate start command:
5152
```bash

cmd/start_web.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
const (
1414
flagPort = "port"
1515
flagAuthorizationToken = "authorization-token"
16-
flagDisks = "disks"
16+
flagMonitorDisks = "monitor-disks"
1717
flagDebug = "debug"
1818

1919
flagBrand = "brand"
@@ -53,7 +53,7 @@ func GetStartWebCmd() *cobra.Command {
5353
nodeHomeDirectory := strings.TrimSpace(args[0])
5454
port, _ := cmd.Flags().GetUint16(flagPort)
5555
authorizationToken, _ := cmd.Flags().GetString(flagAuthorizationToken)
56-
disks, _ := cmd.Flags().GetStringSlice(flagDisks)
56+
monitorDisks, _ := cmd.Flags().GetStringSlice(flagMonitorDisks)
5757
debug, _ := cmd.Flags().GetBool(flagDebug)
5858

5959
brand, _ := cmd.Flags().GetString(flagBrand)
@@ -84,31 +84,35 @@ func GetStartWebCmd() *cobra.Command {
8484
return
8585
}
8686

87-
if disks == nil || len(disks) == 0 {
88-
utils.ExitWithErrorMsgf("ERR: disks is required, use --%s flag to set it\n", flagDisks)
87+
if monitorDisks == nil || len(monitorDisks) == 0 {
88+
utils.ExitWithErrorMsgf("ERR: disks are required, use --%s flag to set it\n", flagMonitorDisks)
8989
return
9090
}
91-
for _, disk := range disks {
92-
disk := strings.TrimSpace(disk)
93-
if !strings.HasPrefix(disk, "/") {
94-
utils.ExitWithErrorMsgf("ERR: disk must be absolute path, correct the --%s flag\n", flagDisks)
91+
for _, disk := range monitorDisks {
92+
monitorDisk := strings.TrimSpace(disk)
93+
if !strings.HasPrefix(monitorDisk, "/") {
94+
utils.ExitWithErrorMsgf("ERR: disk must be absolute path, correct the --%s flag\n", flagMonitorDisks)
9595
return
9696
}
97-
if strings.HasPrefix(disk, "/dev") {
98-
utils.ExitWithErrorMsgf("ERR: disk must be path, not device, correct the --%s flag\n", flagDisks)
97+
if strings.HasPrefix(monitorDisk, "/dev") {
98+
utils.ExitWithErrorMsgf("ERR: disk must be filesystem path, not device, correct the --%s flag\n", flagMonitorDisks)
9999
return
100100
}
101-
_, exists, isDir, err := utils.FileInfo(disk)
101+
_, exists, isDir, err := utils.FileInfo(monitorDisk)
102102
if err != nil {
103-
utils.ExitWithErrorMsgf("ERR: disk %s is invalid, correct the --%s flag\n", disk, flagDisks)
103+
utils.ExitWithErrorMsgf("ERR: disk %s is invalid, correct the --%s flag\n", monitorDisk, flagMonitorDisks)
104104
return
105105
}
106106
if !exists {
107-
utils.ExitWithErrorMsgf("ERR: disk %s does not exists, correct the --%s flag\n", disk, flagDisks)
107+
utils.ExitWithErrorMsgf("ERR: disk %s does not exists, correct the --%s flag\n", monitorDisk, flagMonitorDisks)
108108
return
109109
}
110110
if !isDir {
111-
utils.ExitWithErrorMsgf("ERR: disk %s is not a directory, correct the --%s flag\n", disk, flagDisks)
111+
utils.ExitWithErrorMsgf(
112+
"ERR: disk %s is not a directory, must be filesystem path, correct the --%s flag\n",
113+
monitorDisk,
114+
flagMonitorDisks,
115+
)
112116
return
113117
}
114118
}
@@ -201,7 +205,7 @@ func GetStartWebCmd() *cobra.Command {
201205
web_server.StartWebServer(webtypes.Config{
202206
Port: port,
203207
AuthorizeToken: authorizationToken,
204-
Disks: disks,
208+
MonitorDisks: monitorDisks,
205209
NodeHome: nodeHomeDirectory,
206210
Debug: debug,
207211

@@ -227,7 +231,7 @@ func GetStartWebCmd() *cobra.Command {
227231

228232
cmd.Flags().Uint16(flagPort, defaultWebPort, "port to bind Web service to")
229233
cmd.Flags().StringP(flagAuthorizationToken, "a", "", "authorization token")
230-
cmd.Flags().StringSlice(flagDisks, []string{"/"}, "disks to monitor, must be path, mount-point, not device")
234+
cmd.Flags().StringSlice(flagMonitorDisks, []string{"/"}, "disks to monitor, must be path, mount-point, not device")
231235
cmd.Flags().Bool(flagDebug, false, "enable debug mode")
232236

233237
cmd.Flags().String(flagBrand, defaultBrand, "brand")

services/web_server/handle_api_internal_monitoring_stats.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func HandleApiInternalMonitoringStats(c *gin.Context) {
1616

1717
cpuInfo := make(map[string]any)
1818
vmInfo := make(map[string]any)
19-
disks := make([]map[string]any, 0)
19+
disksInfo := make([]map[string]any, 0)
2020

2121
pCore, errPCore := cpu.Counts(false)
2222
if errPCore == nil {
@@ -40,15 +40,15 @@ func HandleApiInternalMonitoringStats(c *gin.Context) {
4040
vmInfo["used_percent"] = normalizePercentage(vm.UsedPercent)
4141
}
4242

43-
for _, _disk := range cfg.Disks {
44-
du, err := disk.Usage(_disk)
43+
for _, monitorDisk := range cfg.MonitorDisks {
44+
du, err := disk.Usage(monitorDisk)
4545
if err != nil {
46-
utils.PrintlnStdErr("ERR: failed to get disk spec", "disk", _disk, "error", err.Error())
46+
utils.PrintlnStdErr("ERR: failed to get disk spec", "disk", monitorDisk, "error", err.Error())
4747
continue
4848
}
4949

50-
disks = append(disks, map[string]any{
51-
"mount": _disk,
50+
disksInfo = append(disksInfo, map[string]any{
51+
"mount": monitorDisk,
5252
"total": convertByteToGb(du.Total),
5353
"used": convertByteToGb(du.Used),
5454
"used_percent": normalizePercentage(du.UsedPercent),
@@ -58,7 +58,7 @@ func HandleApiInternalMonitoringStats(c *gin.Context) {
5858
w.PrepareDefaultSuccessResponse(map[string]any{
5959
"cpu": cpuInfo,
6060
"ram": vmInfo,
61-
"disks": disks,
61+
"disks": disksInfo,
6262
}).SendResponse()
6363
}
6464

services/web_server/types/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "path"
55
type Config struct {
66
Port uint16
77
AuthorizeToken string
8-
Disks []string
8+
MonitorDisks []string
99
NodeHome string
1010
Debug bool
1111

0 commit comments

Comments
 (0)