feature(worker): added worker http server config

This commit is contained in:
bigeagle 2016-04-28 10:50:51 +08:00
parent 731fba842f
commit 8b56fda1e9
No known key found for this signature in database
GPG Key ID: 9171A4571C27920A
2 changed files with 17 additions and 0 deletions

View File

@ -49,6 +49,7 @@ func (p *ProviderEnum) UnmarshalText(text []byte) error {
type Config struct {
Global globalConfig `toml:"global"`
Manager managerConfig `toml:"manager"`
Server serverConfig `toml:"server"`
Mirrors []mirrorConfig `toml:"mirrors"`
}
@ -66,6 +67,14 @@ type managerConfig struct {
Token string `toml:"token"`
}
type serverConfig struct {
Hostname string `toml:"hostname"`
Addr string `toml:"listen_addr"`
Port int `toml:"listen_port"`
SSLCert string `toml:"ssl_cert"`
SSLKey string `toml:"ssl_key"`
}
type mirrorConfig struct {
Name string `toml:"name"`
Provider ProviderEnum `toml:"provider"`

View File

@ -21,6 +21,13 @@ interval = 240
api_base = "https://127.0.0.1:5000"
token = "some_token"
[server]
hostname = "worker1.example.com"
listen_addr = "127.0.0.1"
listen_port = 6000
ssl_cert = "/etc/tunasync.d/worker1.cert"
ssl_key = "/etc/tunasync.d/worker1.key"
[[mirrors]]
name = "AOSP"
provider = "command"
@ -68,6 +75,7 @@ exclude_file = "/etc/tunasync.d/fedora-exclude.txt"
So(cfg.Global.MirrorDir, ShouldEqual, "/data/mirrors")
So(cfg.Manager.APIBase, ShouldEqual, "https://127.0.0.1:5000")
So(cfg.Server.Hostname, ShouldEqual, "worker1.example.com")
m := cfg.Mirrors[0]
So(m.Name, ShouldEqual, "AOSP")