Skip to content

Commit 8b6e675

Browse files
committed
add README.md
1 parent 2e54749 commit 8b6e675

2 files changed

Lines changed: 58 additions & 9 deletions

File tree

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
1-
# cloudtask-initconfig
2-
cloudtask init serverconfig console app.
1+
# Cloudtask InitConfig
2+
3+
The cloudtask platform initialize configuration tool.
4+
5+
### Dependencies
6+
7+
- [Zookeeper cluster 3.4.6+](https://zookeeper.apache.org)
8+
9+
- [Mongodb cluster 3.0.12+](https://www.mongodb.com)
10+
11+
12+
### Usage
13+
14+
``` bash
15+
$ ./cloudtask-initconfig -f ./ServerConfig.json
16+
```
17+
18+
### ServerConfig.json
19+
20+
``` json
21+
{
22+
"zookeeper": {
23+
"hosts": "192.168.2.80:2181,192.168.2.81:2181,192.168.2.82:2181",
24+
"root": "/cloudtask"
25+
},
26+
"serverconfig": {
27+
"websitehost": "192.168.2.80:8091",
28+
"centerhost": "192.168.2.80:8985",
29+
"storagedriver": {
30+
"mongo": {
31+
"hosts": "192.168.2.80:27017,192.168.2.81:27017,192.168.2.82:27017",
32+
"database": "cloudtask",
33+
"auth": {
34+
"user": "datastoreAdmin",
35+
"password": "ds4dev"
36+
},
37+
"options": [
38+
"maxPoolSize=20",
39+
"replicaSet=mgoCluster",
40+
"authSource=admin"
41+
]
42+
}
43+
}
44+
}
45+
}
46+
```

main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "github.com/samuel/go-zookeeper/zk"
55
import (
66
"bytes"
77
"encoding/json"
8+
"flag"
89
"fmt"
910
"io/ioutil"
1011
"strings"
@@ -19,9 +20,9 @@ type Configuration struct {
1920
Root string `json:"root"`
2021
} `json:"zookeeper"`
2122
ServerConfig struct {
22-
WebsiteHost string `json:"websitehost"`
23-
CenterHost string `json:"centerhost"`
24-
StorageDriver map[string]interface{} `json:"storagedriver"`
23+
WebsiteHost string `json:"websitehost"`
24+
CenterHost string `json:"centerhost"`
25+
StorageDriver map[string]interface{} `json:"storagedriver"`
2526
} `json:"serverconfig"`
2627
}
2728

@@ -71,9 +72,9 @@ func initServerConfigData(conf *Configuration) (string, []byte, error) {
7172
return serverConfigPath, data, nil
7273
}
7374

74-
func readConfiguration() (*Configuration, error) {
75+
func readConfiguration(configFile string) (*Configuration, error) {
7576

76-
data, err := ioutil.ReadFile("./ServerConfig.json")
77+
data, err := ioutil.ReadFile(configFile)
7778
if err != nil {
7879
return nil, err
7980
}
@@ -88,9 +89,13 @@ func readConfiguration() (*Configuration, error) {
8889

8990
func main() {
9091

91-
conf, err := readConfiguration()
92+
var configFile string
93+
flag.StringVar(&configFile, "f", "./ServerConfig.json", "server config file path.")
94+
flag.Parse()
95+
96+
conf, err := readConfiguration(configFile)
9297
if err != nil {
93-
fmt.Printf("ServerConfig.json invalid, %s", err)
98+
fmt.Printf("server config file invalid, %s", err)
9499
return
95100
}
96101

0 commit comments

Comments
 (0)