Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b60aa54

Browse files
committedJul 25, 2018
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 4 additions & 9 deletions
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

Lines changed: 6 additions & 6 deletions
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
}

‎main.go

Lines changed: 233 additions & 191 deletions
Large diffs are not rendered by default.

‎trayicon.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
package main
3232

3333
import (
34-
"flag"
3534
"os"
3635
"path/filepath"
3736
"runtime"
@@ -42,7 +41,6 @@ import (
4241
"github.com/go-ini/ini"
4342
"github.com/kardianos/osext"
4443
"github.com/skratchdot/open-golang/open"
45-
"github.com/vharitonsky/iniflags"
4644
"go.bug.st/serial.v1"
4745
)
4846

@@ -133,7 +131,7 @@ func setupSysTrayReal() {
133131
mConfigCheckbox = append(mConfigCheckbox, entry)
134132
// decorate configs
135133
gliph := " ☐ "
136-
if *configIni == config.Localtion {
134+
if *additionalConfig == config.Localtion {
137135
gliph = " 🗹 "
138136
}
139137
entry.SetTitle(gliph + config.Name)
@@ -150,16 +148,8 @@ func setupSysTrayReal() {
150148
go func(v int) {
151149
for {
152150
<-mConfigCheckbox[v].ClickedCh
153-
flag.Set("config", configs[v].Localtion)
154-
iniflags.UpdateConfig()
155-
applyEnvironment(configs[v].Localtion)
156-
mConfigCheckbox[v].SetTitle(" 🗹 " + configs[v].Name)
157-
//mConfigCheckbox[v].Check()
158-
for j, _ := range mConfigCheckbox {
159-
if j != v {
160-
mConfigCheckbox[j].SetTitle(" ☐ " + configs[j].Name)
161-
}
162-
}
151+
152+
restart("", "-additional-config", configs[v].Localtion)
163153
}
164154
}(i)
165155
}

‎vendor/github.com/vharitonsky/iniflags/LICENSE

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎vendor/github.com/vharitonsky/iniflags/README.md

Lines changed: 0 additions & 141 deletions
This file was deleted.

‎vendor/github.com/vharitonsky/iniflags/iniflags.go

Lines changed: 0 additions & 409 deletions
This file was deleted.

‎vendor/github.com/vharitonsky/iniflags/test_bom.ini

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎vendor/github.com/vharitonsky/iniflags/test_config.ini

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎vendor/github.com/vharitonsky/iniflags/test_config2.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎vendor/github.com/vharitonsky/iniflags/test_setconfigfile.ini

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎vendor/vendor.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,6 @@
206206
"revision": "c8748311a7528d0ba7330d302adbc5a677ef9c9e",
207207
"revisionTime": "2015-02-21T09:03:35-05:00"
208208
},
209-
{
210-
"path": "github.com/vharitonsky/iniflags",
211-
"revision": "02b57ef987a5ee59eedc7dcd93315a43f6dcc4a7",
212-
"revisionTime": "2015-11-14T13:23:54+02:00"
213-
},
214209
{
215210
"path": "github.com/xrash/smetrics",
216211
"revision": "81a89232431423f9140fa413823ce3045f02f19c",

0 commit comments

Comments
 (0)
Please sign in to comment.