Skip to content

Commit 31c8d73

Browse files
authoredJul 27, 2018
Merge pull request #243 from arduino/devel
Deploy configuration overhaul and support for proxies
2 parents a9815a6 + 0d99e2f commit 31c8d73

File tree

13 files changed

+283
-831
lines changed

13 files changed

+283
-831
lines changed
 

‎config.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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://local.arduino.cc:8080
8+
#httpProxy = http://your.proxy:port # Proxy server for HTTP requests

‎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: 268 additions & 192 deletions
Large diffs are not rendered by default.

‎trayicon.go

Lines changed: 3 additions & 31 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

@@ -101,21 +99,6 @@ func getConfigs() []ConfigIni {
10199
return configs
102100
}
103101

104-
func applyEnvironment(filename string) {
105-
src, _ := osext.Executable()
106-
dest := filepath.Dir(src)
107-
cfg, _ := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, filepath.Join(dest, filename))
108-
defaultSection, err := cfg.GetSection("env")
109-
if err != nil {
110-
return
111-
}
112-
for _, env := range defaultSection.KeyStrings() {
113-
val := defaultSection.Key(env).String()
114-
log.Info("Applying env setting: " + env + "=" + val)
115-
os.Setenv(env, val)
116-
}
117-
}
118-
119102
func setupSysTrayReal() {
120103

121104
systray.SetIcon(icon.GetIcon())
@@ -133,14 +116,11 @@ func setupSysTrayReal() {
133116
mConfigCheckbox = append(mConfigCheckbox, entry)
134117
// decorate configs
135118
gliph := " ☐ "
136-
if *configIni == config.Localtion {
119+
if *additionalConfig == config.Localtion {
137120
gliph = " 🗹 "
138121
}
139122
entry.SetTitle(gliph + config.Name)
140123
}
141-
} else {
142-
// apply env setting from first config immediately
143-
// applyEnvironment(configs[0].Localtion)
144124
}
145125
//mQuit := systray.AddMenuItem("Quit Plugin", "")
146126

@@ -150,16 +130,8 @@ func setupSysTrayReal() {
150130
go func(v int) {
151131
for {
152132
<-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-
}
133+
134+
restart("", "-additional-config", configs[v].Localtion)
163135
}
164136
}(i)
165137
}

‎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.