()
| 199 | } |
| 200 | |
| 201 | func run() { |
| 202 | telemetry := z.NewSuperFlag(Zero.Conf.GetString("telemetry")). |
| 203 | MergeAndCheckDefault(x.TelemetryDefaults) |
| 204 | |
| 205 | x.PrintVersion() |
| 206 | tlsConf, err := x.LoadClientTLSConfigForInternalPort(Zero.Conf) |
| 207 | x.Check(err) |
| 208 | |
| 209 | raft := z.NewSuperFlag(Zero.Conf.GetString("raft")).MergeAndCheckDefault( |
| 210 | raftDefaults) |
| 211 | auditConf := audit.GetAuditConf(Zero.Conf.GetString("audit")) |
| 212 | limit := z.NewSuperFlag(Zero.Conf.GetString("limit")).MergeAndCheckDefault( |
| 213 | worker.ZeroLimitsDefaults) |
| 214 | limitConf := &x.LimiterConf{ |
| 215 | UidLeaseLimit: limit.GetUint64("uid-lease"), |
| 216 | RefillAfter: limit.GetDuration("refill-interval"), |
| 217 | } |
| 218 | opts = options{ |
| 219 | telemetry: telemetry, |
| 220 | raft: raft, |
| 221 | limit: limit, |
| 222 | bindall: Zero.Conf.GetBool("bindall"), |
| 223 | portOffset: Zero.Conf.GetInt("port_offset"), |
| 224 | numReplicas: Zero.Conf.GetInt("replicas"), |
| 225 | peer: Zero.Conf.GetString("peer"), |
| 226 | w: Zero.Conf.GetString("wal"), |
| 227 | rebalanceInterval: Zero.Conf.GetDuration("rebalance_interval"), |
| 228 | tlsClientConfig: tlsConf, |
| 229 | audit: auditConf, |
| 230 | limiterConfig: limitConf, |
| 231 | } |
| 232 | glog.Infof("Setting Config to: %+v", opts) |
| 233 | x.WorkerConfig.Parse(Zero.Conf) |
| 234 | |
| 235 | if opts.numReplicas < 0 || opts.numReplicas%2 == 0 { |
| 236 | log.Fatalf("ERROR: Number of replicas must be odd for consensus. Found: %d", |
| 237 | opts.numReplicas) |
| 238 | } |
| 239 | |
| 240 | if opts.audit != nil { |
| 241 | wd, err := filepath.Abs(opts.w) |
| 242 | x.Check(err) |
| 243 | ad, err := filepath.Abs(opts.audit.Output) |
| 244 | x.Check(err) |
| 245 | x.AssertTruef(ad != wd, |
| 246 | "WAL directory and Audit output cannot be the same ('%s').", opts.audit.Output) |
| 247 | } |
| 248 | |
| 249 | if opts.rebalanceInterval <= 0 { |
| 250 | log.Fatalf("ERROR: Rebalance interval must be greater than zero. Found: %d", |
| 251 | opts.rebalanceInterval) |
| 252 | } |
| 253 | |
| 254 | addr := "localhost" |
| 255 | if opts.bindall { |
| 256 | addr = "0.0.0.0" |
| 257 | } |
| 258 | if x.WorkerConfig.MyAddr == "" { |
no test coverage detected