removed configFile

pull/40/head
alok 6 years ago
parent fc18e354ec
commit 00befb04fe
  1. 20
      aws-experiment-launch/experiment/commander/main.go
  2. 2
      aws-experiment-launch/experiment/soldier/main.go

@ -18,7 +18,6 @@ import (
type commanderSetting struct { type commanderSetting struct {
ip string ip string
port string port string
configFile string
configURL string configURL string
configs [][]string configs [][]string
} }
@ -33,11 +32,11 @@ var (
session sessionInfo session sessionInfo
) )
func readConfigFile() [][]string { func readConfigFile(configFile string) [][]string {
file, err := os.Open(setting.configFile) file, err := os.Open(configFile)
defer file.Close() defer file.Close()
if err != nil { if err != nil {
log.Fatal("Failed to read config file ", setting.configFile, log.Fatal("Failed to read config file ", configFile,
"\nNOTE: The config path should be relative to commander.") "\nNOTE: The config path should be relative to commander.")
} }
fscanner := bufio.NewScanner(file) fscanner := bufio.NewScanner(file)
@ -59,7 +58,8 @@ func handleCommand(command string) {
switch cmd := args[0]; cmd { switch cmd := args[0]; cmd {
case "config": case "config":
{ {
out, err := os.Create(setting.configFile) configFile := "distribution_config.txt"
out, err := os.Create(configFile)
if err != nil { if err != nil {
log.Fatal("Failed to create local file", err) log.Fatal("Failed to create local file", err)
} }
@ -79,13 +79,13 @@ func handleCommand(command string) {
} }
// log config file // log config file
content, err := ioutil.ReadFile(setting.configFile) content, err := ioutil.ReadFile(configFile)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
log.Println("Successfully downloaded config") log.Println("Successfully downloaded config")
log.Println(string(content)) log.Println(string(content))
setting.configs = readConfigFile() setting.configs = readConfigFile(configFile)
log.Println("Loaded config file", setting.configs) log.Println("Loaded config file", setting.configs)
} }
case "init": case "init":
@ -113,10 +113,9 @@ func handleCommand(command string) {
} }
} }
func config(ip string, port string, configFile string, configURL string) { func config(ip string, port string, configURL string) {
setting.ip = ip setting.ip = ip
setting.port = port setting.port = port
setting.configFile = configFile
setting.configURL = configURL setting.configURL = configURL
} }
@ -222,11 +221,10 @@ func serve() {
func main() { func main() {
ip := flag.String("ip", "127.0.0.1", "The ip of commander, i.e. this machine") ip := flag.String("ip", "127.0.0.1", "The ip of commander, i.e. this machine")
port := flag.String("port", "8080", "The port which the commander uses to communicate with soldiers") port := flag.String("port", "8080", "The port which the commander uses to communicate with soldiers")
configFile := flag.String("config_file", "distribution_config.txt", "The file name of config file")
configURL := flag.String("config_url", "http://unique-bucket-bin.amazonaws.com/distribution_config.txt", "The config URL") configURL := flag.String("config_url", "http://unique-bucket-bin.amazonaws.com/distribution_config.txt", "The config URL")
flag.Parse() flag.Parse()
config(*ip, *port, *configFile, *configURL) config(*ip, *port, *configURL)
log.Println("Start to host config files at http://" + setting.ip + ":" + setting.port) log.Println("Start to host config files at http://" + setting.ip + ":" + setting.port)

@ -126,8 +126,6 @@ func handleInitCommand(args []string, w *bufio.Writer) {
configURL := args[2] configURL := args[2]
sessionID := args[3] sessionID := args[3]
session.id = sessionID session.id = sessionID
//configURL := fmt.Sprintf("http://%v:%v/%v", ip, port, configFile)
session.logFolder = fmt.Sprintf("../tmp_log/log-%v", sessionID) session.logFolder = fmt.Sprintf("../tmp_log/log-%v", sessionID)
// create local config file // create local config file

Loading…
Cancel
Save