Skip to content

Commit b60aa54

Browse files
committed
Handle config better
Eliminated iniflags, used a flagset to handle inheritance of config. Changing config restarts the process (so that it can be instantiated again)
1 parent 213356e commit b60aa54

File tree

13 files changed

+247
-812
lines changed

13 files changed

+247
-812
lines changed

config.ini

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
configUpdateInterval = 0 # Update interval for re-reading config file set via -config flag. Zero disables config file re-reading.
21
gc = std # Type of garbage collection. std = Normal garbage collection allowing system to decide (this has been known to cause a stop the world in the middle of a CNC job which can cause lost responses from the CNC controller and thus stalled jobs. use max instead to solve.), off = let memory grow unbounded (you have to send in the gc command manually to garbage collect or you will run out of RAM eventually), max = Force garbage collection on each recv or send on a serial port (this minimizes stop the world events and thus lost serial responses, but increases CPU usage)
32
hostname = unknown-hostname # Override the hostname we get from the OS
4-
ls = false # launch self 5 seconds later
53
regex = usb|acm|com # Regular expression to filter serial port list
64
v = true # show debug logging
75
appName = CreateBridge
86
updateUrl = http://downloads.arduino.cc/
7+
origins = http://downloads.arduino.cc/

hub.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func exit() {
276276

277277
}
278278

279-
func restart(path string) {
279+
func restart(path string, args ...string) {
280280
log.Println("called restart", path)
281281
quitSysTray()
282282
// relaunch ourself and exit
@@ -302,14 +302,9 @@ func restart(path string) {
302302

303303
exePath = strings.Trim(exePath, "\n")
304304

305-
hiberString := ""
306-
if *hibernate == true {
307-
hiberString = "-hibernate"
308-
}
309-
310-
cmd := exec.Command(exePath, "-ls", "-regex", *regExpFilter, "-gc", *gcType, hiberString)
311-
312-
fmt.Println(cmd)
305+
args = append(args, "-ls")
306+
args = append(args, "-hibernate="+fmt.Sprint(*hibernate))
307+
cmd := exec.Command(exePath, args...)
313308

314309
err := cmd.Start()
315310
if err != nil {

info.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ func infoHandler(c *gin.Context) {
1313
host = parts[0]
1414

1515
c.JSON(200, gin.H{
16-
"version": version,
17-
"http": "http://" + host + port,
18-
"https": "https://localhost" + portSSL,
19-
"ws": "ws://" + host + port,
20-
"wss": "wss://localhost" + portSSL,
21-
"origins": origins,
16+
"version": version,
17+
"http": "http://" + host + port,
18+
"https": "https://localhost" + portSSL,
19+
"ws": "ws://" + host + port,
20+
"wss": "wss://localhost" + portSSL,
21+
"origins": origins,
2222
"update_url": updateUrl,
2323
})
2424
}

0 commit comments

Comments
 (0)