| OLD | NEW |
| 1 // Common tool initialization. | 1 // Common tool initialization. |
| 2 // import only from package main. | 2 // import only from package main. |
| 3 package common | 3 package common |
| 4 | 4 |
| 5 import ( | 5 import ( |
| 6 "flag" | 6 "flag" |
| 7 "fmt" | 7 "fmt" |
| 8 "net" | 8 "net" |
| 9 "os" | 9 "os" |
| 10 "runtime" | 10 "runtime" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // Note(stephana): getGraphiteServer relies on Init() being called first
. | 50 // Note(stephana): getGraphiteServer relies on Init() being called first
. |
| 51 startMetrics(appName, getGraphiteServer()) | 51 startMetrics(appName, getGraphiteServer()) |
| 52 } | 52 } |
| 53 | 53 |
| 54 // TODO(stephana): Refactor startMetrics to return an error instead of | 54 // TODO(stephana): Refactor startMetrics to return an error instead of |
| 55 // terminating the app. | 55 // terminating the app. |
| 56 | 56 |
| 57 func startMetrics(appName, graphiteServer string) { | 57 func startMetrics(appName, graphiteServer string) { |
| 58 if graphiteServer == "" { | 58 if graphiteServer == "" { |
| 59 » » glog.Warningf("No metrics server speicifed.") | 59 » » glog.Warningf("No metrics server specified.") |
| 60 return | 60 return |
| 61 } | 61 } |
| 62 | 62 |
| 63 addr, err := net.ResolveTCPAddr("tcp", graphiteServer) | 63 addr, err := net.ResolveTCPAddr("tcp", graphiteServer) |
| 64 if err != nil { | 64 if err != nil { |
| 65 glog.Fatalf("Unable to resolve metrics server address: %s", err) | 65 glog.Fatalf("Unable to resolve metrics server address: %s", err) |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Get the hostname and create the app-prefix. | 68 // Get the hostname and create the app-prefix. |
| 69 hostName, err := os.Hostname() | 69 hostName, err := os.Hostname() |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 func DecodeTomlFile(filename string, configuration interface{}) { | 91 func DecodeTomlFile(filename string, configuration interface{}) { |
| 92 if _, err := toml.DecodeFile(filename, configuration); err != nil { | 92 if _, err := toml.DecodeFile(filename, configuration); err != nil { |
| 93 glog.Fatalf("Failed to decode config file %s: %s", filename, err
) | 93 glog.Fatalf("Failed to decode config file %s: %s", filename, err
) |
| 94 } | 94 } |
| 95 | 95 |
| 96 conf_str := spew.Sdump(configuration) | 96 conf_str := spew.Sdump(configuration) |
| 97 glog.Infof("Read TOML configuration from %s: %s", filename, conf_str) | 97 glog.Infof("Read TOML configuration from %s: %s", filename, conf_str) |
| 98 } | 98 } |
| OLD | NEW |