// LoadConfig loads a config yaml from a file on disk.
// if the pid is not set in the yaml, pull it from the environment TRANSPORTER_PID.
// if that env var isn't present, then generate a pid
LoadConfig loads a config yaml from a file on disk.
if the pid is not set in the yaml, pull it from the environment TRANSPORTER_PID.
if that env var isn't present, then generate a pid
// LoadConfig loads a config yaml from a file on disk . // if the pid is not set in the yaml pull it from the environment TRANSPORTER_PID . // if that env var isn ' t present then generate a pid
func LoadConfig(filename string) (config Config, err error) {
	if filename == "" {
		if _, err := os.Stat("config.yaml"); os.IsNotExist(err) {
			return config, nil 
		}
		filename = "config.yaml"
	}
	ba, err := ioutil.ReadFile(filename)
	if err != nil {
		return
	}
	ba = setConfigEnvironment(ba)
	err = yaml.Unmarshal(ba, &config)
	for k, v := range config.Nodes {
		config.Nodes[k] = v
	}
	if len(config.API.Pid) < 1 {
		config.API.Pid = os.Getenv("TRANSPORTER_PID")
	}
	if len(config.API.Pid) < 1 {
		hostname, _ := os.Hostname()
		config.API.Pid = fmt.Sprintf("%s@%d", hostname, time.Now().Unix())
	}
	return
}
func LoadConfig ( filename string ) ( config Config , err error ) { if filename == " " { if _ , err := os . Stat ( " " ) ; os . IsNotExist ( err ) { return config , nil } filename = " " } ba , err := ioutil . ReadFile ( filename ) if err != nil { return } ba = setConfigEnvironment ( ba ) err = yaml . Unmarshal ( ba , & config ) for k , v := range config . Nodes { config . Nodes [ k ] = v } if len ( config . API . Pid ) < 1 { config . API . Pid = os . Getenv ( " " ) } if len ( config . API . Pid ) < 1 { hostname , _ := os . Hostname ( ) config . API . Pid = fmt . Sprintf ( " " , hostname , time . Now ( ) . Unix ( ) ) } return }
LoadConfig loads a config yaml from a file on disk.
LoadConfig loads a config yaml from a file on disk .
// return the default config // configs can have environment variables, replace these before continuing