44 lines
663 B
Go
44 lines
663 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
var config = &Config{}
|
|
|
|
func init() {
|
|
f, err := os.Open("config.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
dec := yaml.NewDecoder(f)
|
|
err = dec.Decode(config)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Config 本地yaml配置对象
|
|
type Config struct {
|
|
Server struct {
|
|
URI string `yaml:"uri"`
|
|
} `yaml:"server"`
|
|
|
|
ChromeProxy struct {
|
|
Host string `yaml:"host"`
|
|
} `yaml:"chromeproxy"`
|
|
}
|
|
|
|
func initChromeProxy() {
|
|
err := exec.Command("google-chrome",
|
|
"http://eson.config?taskurl="+config.ChromeProxy.Host,
|
|
"--user-data-dir=/tmp/chromeproxy-userdata",
|
|
).Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|